英語で読む

次の方法で共有


DnsPermission.Union(IPermission) メソッド

定義

現在のアクセス許可インスタンスと指定したアクセス許可インスタンスの和集合を表すアクセス許可インスタンスを作成します。

public override System.Security.IPermission Union (System.Security.IPermission target);

パラメーター

target
IPermission

現在のインスタンスと組み合わせる DnsPermission インスタンス。

戻り値

現在の DnsPermission インスタンスと指定した DnsPermission インスタンスの和集合を表す DnsPermission インスタンス。 targetnull の場合、このメソッドは現在のインスタンスのコピーを返します。 現在のインスタンスまたは target が無制限である場合、このメソッドは無制限の DnsPermission インスタンスを返します。それ以外の場合は、制限付きの DnsPermission インスタンスを返します。

例外

targetDnsPermission でも null でもありません。

次の例では、現在のアクセス許可インスタンスと指定されたアクセス許可インスタンスの和集合であるアクセス許可インスタンスを作成します。

private void MyUnion()
{
   // Create a DnsPermission instance that is the union of the current DnsPermission
   // instance and the specified DnsPermission instance.
   DnsPermission permission = (DnsPermission)dnsPermission1.Union(dnsPermission2);
   // Print the attributes and the values of the union 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();
}

注釈

メソッドは UnionDnsPermission 現在 DnsPermission のインスタンスまたは指定された DnsPermission インスタンスによって定義されたアクセスを許可するインスタンスを返します。 いずれかのアクセス許可を渡す要求は、その共用体を渡します。

適用対象

製品 バージョン
.NET 6 (package-provided), 7 (package-provided), 8 (package-provided), 9 (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 (package-provided), 4.7, 4.7.1 (package-provided), 4.7.1, 4.7.2 (package-provided), 4.7.2, 4.8 (package-provided), 4.8, 4.8.1
.NET Standard 2.0 (package-provided)
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9