Export (0) Print
Expand All

DnsPermission.IsSubsetOf Method

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

Namespace: System.Net
Assembly: System (in system.dll)

'Declaration
Public Overrides Function IsSubsetOf ( _
	target As IPermission _
) As Boolean
'Usage
Dim instance As DnsPermission
Dim target As IPermission
Dim returnValue As Boolean

returnValue = instance.IsSubsetOf(target)
public boolean IsSubsetOf (
	IPermission target
)
public override function IsSubsetOf (
	target : IPermission
) : boolean
Not applicable.

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.

Exception typeCondition

ArgumentException

target is neither a DnsPermission nor a null reference (Nothing in Visual Basic).

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.

The following example uses the IsSubsetOf method to determine whether the current permission instance is a subset of the specified permission instance.

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


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().get_Attributes());
    Console.WriteLine("Attributes and Values of specified "
        + "'DnsPermission' instance :");
    PrintKeysAndValues(dnsPermission1.ToXml().get_Attributes());
    Subset(dnsPermission1);
} //UseDns

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.");
    }
} //Subset

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.get_Key(),
            myEnumerator.get_Value());
    }
    Console.WriteLine();
} //PrintKeysAndValues

Windows 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

Community Additions

ADD
Show:
© 2014 Microsoft