Aracılığıyla paylaş


DnsPermission.IsSubsetOf(IPermission) Yöntem

Tanım

Geçerli izin örneğinin belirtilen izin örneğinin bir alt kümesi olup olmadığını belirler.

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

Parametreler

target
IPermission

Alt küme ilişkisi için test edilecek ikinci DnsPermission örnek.

Döndürülenler

false geçerli örnek kısıtlanmamışsa ve target ya da null kısıtlanmamışsa; değilse, true.

Özel durumlar

targetne ne de null.DnsPermission

Örnekler

Aşağıdaki örnek, geçerli izin örneğinin belirtilen izin örneğinin bir alt kümesi olup olmadığını belirlemek için yöntemini kullanır IsSubsetOf .

public:
   void useDns()
   {
      // Create a DnsPermission instance.
      permission = gcnew DnsPermission( PermissionState::Unrestricted );
      DnsPermission^ dnsPermission1 = gcnew DnsPermission( PermissionState::None );
      // Check for permission.
      permission->Demand();
      dnsPermission1->Demand();
      // Print the attributes and values.
      Console::WriteLine( "Attributes and Values of 'DnsPermission' instance :" );
      PrintKeysAndValues( permission->ToXml()->Attributes );
      Console::WriteLine( "Attributes and Values of specified 'DnsPermission' instance :" );
      PrintKeysAndValues( dnsPermission1->ToXml()->Attributes );
      Subset( dnsPermission1 );
   }

private:
   void Subset( DnsPermission^ Permission1 )
   {
      if ( permission->IsSubsetOf( Permission1 ) )
      {
         Console::WriteLine( "Current 'DnsPermission' instance is a subset of specified 'DnsPermission' instance." );
      }
      else
      {
         Console::WriteLine( "Current 'DnsPermission' instance is not a subset of specified 'DnsPermission' instance." );
      }
   }

   void PrintKeysAndValues( Hashtable^ myList )
   {
      // Get the enumerator that can iterate through the hash table.
      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();
   }
public void useDns() {
   // Create a DnsPermission instance.
   permission = new DnsPermission(PermissionState.Unrestricted);
   DnsPermission dnsPermission1 = new DnsPermission(PermissionState.None);
   // Check for permission.
   permission.Demand();
   dnsPermission1.Demand();
   // Print the attributes and values.
   Console.WriteLine("Attributes and Values of 'DnsPermission' instance :");
   PrintKeysAndValues(permission.ToXml().Attributes);
   Console.WriteLine("Attributes and Values of specified 'DnsPermission' instance :");
   PrintKeysAndValues(dnsPermission1.ToXml().Attributes);
   Subset(dnsPermission1);
}

private void Subset(DnsPermission Permission1)
{
   if(permission.IsSubsetOf(Permission1))
      Console.WriteLine("Current 'DnsPermission' instance is a subset of specified 'DnsPermission' instance.");
   else
      Console.WriteLine("Current 'DnsPermission' instance is not a subset of specified 'DnsPermission' instance.");
}

private void PrintKeysAndValues(Hashtable myList) {
   // Get the enumerator that can iterate through the hash table.
   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();
}
Public Sub useDns()
    ' Create a DnsPermission instance.
    permission = New DnsPermission(PermissionState.Unrestricted)
    Dim dnsPermission1 As New DnsPermission(PermissionState.None)
    ' Check  for permission.
    permission.Demand()
    dnsPermission1.Demand()
    ' Print the attributes and values.
    Console.WriteLine("Attributes and Values of 'DnsPermission' instance :")
    PrintKeysAndValues(permission.ToXml().Attributes)
    Console.WriteLine("Attributes and Values of specified 'DnsPermission' instance :")
    PrintKeysAndValues(dnsPermission1.ToXml().Attributes)
    Subset(dnsPermission1)
End Sub


Private Sub Subset(Permission1 As DnsPermission)
    If permission.IsSubsetOf(Permission1) Then
        Console.WriteLine("Current 'DnsPermission' instance is a subset of specified 'DnsPermission' instance.")
    Else
        Console.WriteLine("Current 'DnsPermission' instance is not a subset of specified 'DnsPermission' instance.")
    End If
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

Açıklamalar

Geçerli DnsPermission örnek, belirtilen DnsPermission örnek tarafından tamamen kapsanan bir işlem kümesi belirtiyorsa, geçerli DnsPermission örnek belirtilen DnsPermission örneğin bir alt kümesidir.

IsSubsetOf yöntemi döndürürsetrue, geçerli DnsPermission örnek belirtilen DnsPermission örnekten daha fazla DNS sunucusuna erişime izin vermez.

Şunlara uygulanır