DnsPermission.Intersect(IPermission) 메서드

정의

현재 사용 권한 인스턴스와 지정된 사용 권한 인스턴스의 교집합에 해당하는 사용 권한 인스턴스를 만듭니다.Creates a permission instance that is the intersection of the current permission instance and the specified permission instance.

public:
 override System::Security::IPermission ^ Intersect(System::Security::IPermission ^ target);
public override System.Security.IPermission Intersect (System.Security.IPermission target);
override this.Intersect : System.Security.IPermission -> System.Security.IPermission
Public Overrides Function Intersect (target As IPermission) As IPermission

매개 변수

target
IPermission

현재 인스턴스와 교집합을 구할 DnsPermission 인스턴스입니다.The DnsPermission instance to intersect with the current instance.

반환

현재 DnsPermission 인스턴스와 지정된 DnsPermission 인스턴스의 교집합에 해당하는 부분을 나타내는 DnsPermission 인스턴스이거나 교집합이 비어 있는 경우에는 null입니다.A DnsPermission instance that represents the intersection of the current DnsPermission instance with the specified DnsPermission instance, or null if the intersection is empty. 현재 인스턴스와 target이 모두 무제한이면, 이 메서드는 무제한인 새 DnsPermission 인스턴스를 반환하고, 그렇지 않으면 null을 반환합니다.If both the current instance and target are unrestricted, this method returns a new DnsPermission instance that is unrestricted; otherwise, it returns null.

예외

targetDnsPermission 또는 null이 아닌 경우target is neither a DnsPermission nor null.

예제

다음 예에서는 현재 사용 권한 인스턴스의 교집합에 해당 하는 사용 권한 인스턴스 및 지정한 사용 권한 인스턴스를 만듭니다.The following example creates a permission instance that is the intersection of the current permission instance and the specified permission instance.

public:
   void useDns()
   {
      // Create a DnsPermission instance.
      dnsPermission1 = gcnew DnsPermission( PermissionState::Unrestricted );
      dnsPermission2 = gcnew DnsPermission( PermissionState::None );
      // Check for permission.
      dnsPermission1->Demand();
      dnsPermission2->Demand();
      Console::WriteLine( "Attributes and Values of first DnsPermission instance :" );
      PrintKeysAndValues( dnsPermission1->ToXml()->Attributes );
      Console::WriteLine( "Attributes and Values of second DnsPermission instance :" );
      PrintKeysAndValues( dnsPermission2->ToXml()->Attributes );
      Console::WriteLine( "Union of both instances : " );
      MyUnion();
      Console::WriteLine( "Intersection of both instances : " );
      MyIntersection();
   }

private:
   void PrintKeysAndValues( Hashtable^ myList )
   {
      // Get the enumerator that can iterate through the hash tabble.
      IDictionaryEnumerator^ myEnumerator = myList->GetEnumerator();
      Console::WriteLine( "\t-KEY-\t-VALUE-" );
      while ( myEnumerator->MoveNext() )
      {
         Console::WriteLine( "\t {0}:\t {1}", myEnumerator->Key, myEnumerator->Value );
      }
      Console::WriteLine();
   }

   // Create a DnsPermission instance that is the intersection of current
   // DnsPermission instance and the specified DnsPermission instance.
   void MyIntersection()
   {
      DnsPermission^ permission = dynamic_cast<DnsPermission^>(dnsPermission1->Intersect( dnsPermission2 ));
      // Print the attributes and the values of the intersection instance of
      // DnsPermission.
      PrintKeysAndValues( permission->ToXml()->Attributes );
   }
public void useDns() {
   // Create a DnsPermission instance.
   dnsPermission1 = new DnsPermission(PermissionState.Unrestricted);
   dnsPermission2 = new DnsPermission(PermissionState.None);
   // Check for permission.
   dnsPermission1.Demand();
   dnsPermission2.Demand();
   Console.WriteLine("Attributes and Values of first DnsPermission instance :");
   PrintKeysAndValues(dnsPermission1.ToXml().Attributes);
   Console.WriteLine("Attributes and Values of second DnsPermission instance :");
   PrintKeysAndValues(dnsPermission2.ToXml().Attributes);
   Console.WriteLine("Union of both instances : ");
   MyUnion();
   Console.WriteLine("Intersection of both instances : ");
   MyIntersection();
}

private void PrintKeysAndValues(Hashtable myList) {
   // Get the enumerator that can iterate through the hash tabble.
   IDictionaryEnumerator myEnumerator = myList.GetEnumerator();
   Console.WriteLine("\t-KEY-\t-VALUE-");
   while (myEnumerator.MoveNext())
      Console.WriteLine("\t{0}:\t{1}", myEnumerator.Key, myEnumerator.Value);
   Console.WriteLine();
}
   // Create a DnsPermission instance that is the intersection of current
   // DnsPermission instance and the specified DnsPermission instance.
private void MyIntersection()
{
   DnsPermission permission = (DnsPermission)dnsPermission1.Intersect(dnsPermission2);
   // Print the attributes and the values of the intersection instance of
   // DnsPermission.
   PrintKeysAndValues(permission.ToXml().Attributes);
}
Public Sub useDns()
    ' Create a DnsPermission instance.
    dnsPermission1 = New DnsPermission(PermissionState.Unrestricted)
    dnsPermission2 = New DnsPermission(PermissionState.None)
    ' Check for permission.
    dnsPermission1.Demand()
    dnsPermission2.Demand()
    Console.WriteLine("Attributes and Values of first DnsPermission instance :")
    PrintKeysAndValues(dnsPermission1.ToXml().Attributes)
    Console.WriteLine("Attributes and Values of second DnsPermission instance :")
    PrintKeysAndValues(dnsPermission2.ToXml().Attributes)
    Console.WriteLine("Union of both instances : ")
    MyUnion()
    Console.WriteLine("Intersection of both instances : ")
    MyIntersection()
End Sub

Private Sub PrintKeysAndValues(myList As Hashtable)
    ' Get the enumerator that can iterate through the hash table.
    Dim myEnumerator As IDictionaryEnumerator = myList.GetEnumerator()
    Console.WriteLine(ControlChars.Tab + "-KEY-" + ControlChars.Tab + "-VALUE-")
    While myEnumerator.MoveNext()
        Console.WriteLine(ControlChars.Tab + "{0}:" + ControlChars.Tab + "{1}", myEnumerator.Key, myEnumerator.Value)
    End While
    Console.WriteLine()
End Sub

Private Sub MyIntersection()
    ' Create a DnsPermission instance that is the intersection of the current
    ' DnsPermission instance and the specified DnsPermission instance.
    Dim permission As DnsPermission = CType(dnsPermission1.Intersect(dnsPermission2), DnsPermission)
    ' Print the attributes and values of the intersection instance of DnsPermission.
    PrintKeysAndValues(permission.ToXml().Attributes)
End Sub

설명

Intersect 메서드가 반환 되는 DnsPermission 모두 현재 정의 된 액세스를 허용 하는 인스턴스 DnsPermission 인스턴스와 지정 된 DnsPermission 인스턴스.The Intersect method returns a DnsPermission instance that allows the access defined by both the current DnsPermission instance and the specified DnsPermission instance. 모든 요청 교차점 전달 권한을 모두 전달 해야 합니다.Any demand must pass both permissions to pass their intersection.

적용 대상