Op Englesch liesen Editéieren

Deelen iwwer


DnsPermission.IsSubsetOf(IPermission) Method

Definition

Important

Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.

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

C#
public override bool IsSubsetOf(System.Security.IPermission target);

Parameters

target
IPermission

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

Returns

false if the current instance is unrestricted and target is either null or unrestricted; otherwise, true.

Exceptions

target is neither a DnsPermission nor null.

Examples

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

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();
}

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.

Applies to

Produkt Versiounen
.NET 8 (package-provided), 9 (package-provided), 10 (package-provided)
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0 (package-provided)
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10