Export (0) Print
Expand All

DnsPermission.IsSubsetOf Method

Determines whether the current permission instance is a subset of the specified permission instance.

[Visual Basic]
Overrides Public Function IsSubsetOf( _
   ByVal target As IPermission _
) As Boolean Implements IPermission.IsSubsetOf
[C#]
public override bool IsSubsetOf(
 IPermission target
);
[C++]
public: bool IsSubsetOf(
 IPermission* target
);
[JScript]
public override function IsSubsetOf(
   target : IPermission
) : Boolean;

Parameters

target
The second DnsPermission instance to be tested for the subset relationship.

Return Value

false if the current instance is unrestricted and target is either a null reference (Nothing in Visual Basic) or unrestricted, otherwise true.

Implements

IPermission.IsSubsetOf

Exceptions

Exception Type Condition
ArgumentException target is neither a DnsPermission nor a null reference (Nothing in Visual Basic).

Remarks

The current DnsPermission instance is a subset of the specified DnsPermission instance if the current DnsPermission instance specifies a set of operations that is wholly contained by the specified DnsPermission instance.

If the IsSubsetOf method returns true, the current DnsPermission instance allows no more access to DNS servers than does the specified DnsPermission instance.

Example

[Visual Basic, C#, C++] The following example uses the IsSubsetOf method to determine whether the current permission instance is a subset of the specified permission instance.

[Visual Basic] 
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 'useDns


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 'Subset
 
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 'PrintKeysAndValues


[C#] 
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();
}

[C++] 
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(S"Attributes and Values of 'DnsPermission' instance :");
      PrintKeysAndValues(permission->ToXml()->Attributes);
      Console::WriteLine(S"Attributes and Values of specified 'DnsPermission' instance :");
      PrintKeysAndValues(dnsPermission1->ToXml()->Attributes);
      Subset(dnsPermission1);
   }

private:
   void Subset(DnsPermission* Permission1) 
   {
      if (permission->IsSubsetOf(Permission1))
         Console::WriteLine(S"Current 'DnsPermission' instance is a subset of specified 'DnsPermission' instance.");
      else
         Console::WriteLine(S"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(S"\t-KEY-\t-VALUE-");
      while (myEnumerator->MoveNext())
         Console::WriteLine(S"\t {0}:\t {1}", myEnumerator->Key, myEnumerator->Value);
      Console::WriteLine();
   }

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, Common Language Infrastructure (CLI) Standard

See Also

DnsPermission Class | DnsPermission Members | System.Net Namespace

Show:
© 2014 Microsoft