FirstMatchCodeGroup(IMembershipCondition, PolicyStatement) Konstruktor
Definisi
Penting
Beberapa informasi terkait produk prarilis yang dapat diubah secara signifikan sebelum dirilis. Microsoft tidak memberikan jaminan, tersirat maupun tersurat, sehubungan dengan informasi yang diberikan di sini.
Menginisialisasi instans baru kelas FirstMatchCodeGroup.
public:
FirstMatchCodeGroup(System::Security::Policy::IMembershipCondition ^ membershipCondition, System::Security::Policy::PolicyStatement ^ policy);
public FirstMatchCodeGroup (System.Security.Policy.IMembershipCondition membershipCondition, System.Security.Policy.PolicyStatement policy);
new System.Security.Policy.FirstMatchCodeGroup : System.Security.Policy.IMembershipCondition * System.Security.Policy.PolicyStatement -> System.Security.Policy.FirstMatchCodeGroup
Public Sub New (membershipCondition As IMembershipCondition, policy As PolicyStatement)
Parameter
- membershipCondition
- IMembershipCondition
Kondisi keanggotaan yang menguji bukti untuk menentukan apakah grup kode ini menerapkan kebijakan.
- policy
- PolicyStatement
Pernyataan kebijakan untuk grup kode dalam bentuk set izin dan atribut untuk memberikan kode yang cocok dengan kondisi keanggotaan.
Pengecualian
Jenis membershipCondition
parameter tidak valid.
-atau-
Jenis policy
parameter tidak valid.
Contoh
Kode berikut menunjukkan penggunaan FirstMatchCodeGroup konstruktor. Contoh kode ini adalah bagian dari contoh yang lebih besar yang disediakan untuk FirstMatchCodeGroup kelas.
FileIOPermission^ rootFilePermissions =
gcnew FileIOPermission( PermissionState::None );
rootFilePermissions->AllLocalFiles = FileIOPermissionAccess::Read;
rootFilePermissions->SetPathList( FileIOPermissionAccess::Read, L"C:\\" );
// Add a permission to a named permission set.
NamedPermissionSet^ namedPermissions =
gcnew NamedPermissionSet( L"RootPermissions" );
namedPermissions->AddPermission( rootFilePermissions );
// Create a PolicyStatement with exclusive rights to the policy.
PolicyStatement^ policy = gcnew PolicyStatement(
namedPermissions,PolicyStatementAttribute::Exclusive );
// Create a FirstMatchCodeGroup with a membership condition that
// matches all code, and an exclusive policy.
FirstMatchCodeGroup^ codeGroup = gcnew FirstMatchCodeGroup(
gcnew AllMembershipCondition,policy );
FileIOPermission rootFilePermissions =
new FileIOPermission(PermissionState.None);
rootFilePermissions.AllLocalFiles = FileIOPermissionAccess.Read;
rootFilePermissions.SetPathList(FileIOPermissionAccess.Read,"C:\\");
// Add a permission to a named permission set.
NamedPermissionSet namedPermissions =
new NamedPermissionSet("RootPermissions");
namedPermissions.AddPermission(rootFilePermissions);
// Create a PolicyStatement with exclusive rights to the policy.
PolicyStatement policy = new PolicyStatement(
namedPermissions,PolicyStatementAttribute.Exclusive);
// Create a FirstMatchCodeGroup with a membership condition that
// matches all code, and an exclusive policy.
FirstMatchCodeGroup codeGroup =
new FirstMatchCodeGroup(
new AllMembershipCondition(),
policy);
Dim rootFilePermissions As New FileIOPermission(PermissionState.None)
rootFilePermissions.AllLocalFiles = FileIOPermissionAccess.Read
rootFilePermissions.SetPathList(FileIOPermissionAccess.Read, "C:\\")
' Add a permission to a named permission set.
Dim namedPermissions As New NamedPermissionSet("RootPermissions")
namedPermissions.AddPermission(rootFilePermissions)
' Create a PolicyStatement with exclusive rights to the policy.
Dim policy As New PolicyStatement( _
namedPermissions, _
PolicyStatementAttribute.Exclusive)
' Create a FirstMatchCodeGroup with a membership condition that
' matches all code, and an exclusive policy.
Dim codeGroup As New FirstMatchCodeGroup( _
New AllMembershipCondition, _
policy)
Keterangan
Konstruktor ini membuat grup kode dasar dan harus dipanggil dari konstruktor grup kode kustom. Grup kode anak dapat ditambahkan menggunakan AddChild metode .