다음을 통해 공유


FirstMatchCodeGroup(IMembershipCondition, PolicyStatement) 생성자

정의

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)

매개 변수

membershipCondition
IMembershipCondition

이 코드 그룹에 정책이 적용되는지 여부를 결정하는 증명 정보를 테스트하는 멤버 자격 조건입니다.

policy
PolicyStatement

멤버 자격 조건과 일치하는 코드를 부여하는 권한 집합 및 특성 형식인 코드 그룹의 정책 문입니다.

예외

membershipCondition 매개 변수의 형식이 올바르지 않은 경우

또는

policy 매개 변수의 형식이 올바르지 않은 경우

예제

다음 코드는 생성자의 FirstMatchCodeGroup 사용을 보여줍니다. 이 코드 예제는 클래스에 제공된 FirstMatchCodeGroup 더 큰 예제의 일부입니다.

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)

설명

이 생성자는 기본 코드 그룹을 만들고 사용자 지정 코드 그룹의 생성자에서 호출해야 합니다. 자식 코드 그룹은 메서드를 AddChild 사용하여 추가할 수 있습니다.

적용 대상