GacIdentityPermission.Union メソッド
アセンブリ: mscorlib (mscorlib.dll 内)
構文
Dim instance As GacIdentityPermission Dim target As IPermission Dim returnValue As IPermission returnValue = instance.Union(target)
戻り値
現在のアクセス許可と指定したアクセス許可の和集合を表す新しいアクセス許可。
解説
Union メソッドを呼び出すと、現在のアクセス許可と指定したアクセス許可の両方が表す操作をすべて含むアクセス許可が作成されます。いずれかのアクセス許可を要求し、その要求が満たされた場合、両者の和集合を表すアクセス許可に対する要求も満たされます。
現在のアクセス許可が、指定したアクセス許可と等しい場合、GacIdentityPermission は設定操作 (IsSubsetOf、Intersect、および Union の各メソッド) だけをサポートします。
Union メソッドを使用するコード例を次に示します。このコード例は、GacIdentityPermission クラスのトピックで取り上げているコード例の一部分です。
' Union creates a new permission that is the union of the current permission ' and the specified permission. Private Function UnionDemo() As Boolean Dim Gac1 As New GacIdentityPermission(PermissionState.None) Dim Gac2 As New GacIdentityPermission Try Dim p3 As GacIdentityPermission = CType(Gac1.Union(Gac2), GacIdentityPermission) If Not (p3 Is Nothing) Then Console.WriteLine("The union of two GacIdentityPermissions was successful.") Else Console.WriteLine("The union of two GacIdentityPermissions failed.") Return False End If Catch e As Exception Console.WriteLine(("An exception was thrown : " & e.ToString())) Return False End Try Return True End Function 'UnionDemo
// Union creates a new permission that is the union of the current permission // and the specified permission. private bool UnionDemo() { GacIdentityPermission Gac1 = new GacIdentityPermission(PermissionState.None); GacIdentityPermission Gac2 = new GacIdentityPermission(); try { GacIdentityPermission p3 = (GacIdentityPermission)Gac1.Union(Gac2); if (p3 != null) { Console.WriteLine("The union of two GacIdentityPermissions was successful."); } else { Console.WriteLine("The union of two GacIdentityPermissions failed."); return false; } } catch (Exception e) { Console.WriteLine("An exception was thrown : " + e); return false; } return true; }
// Union creates a new permission that is the union of the current permission // and the specified permission. bool UnionDemo() { GacIdentityPermission ^ Gac1 = gcnew GacIdentityPermission( PermissionState::None ); GacIdentityPermission ^ Gac2 = gcnew GacIdentityPermission; try { GacIdentityPermission ^ p3 = dynamic_cast<GacIdentityPermission^>(Gac1->Union( Gac2 )); if ( p3 != nullptr ) { Console::WriteLine( "The union of two GacIdentityPermissions was successful." ); } else { Console::WriteLine( "The union of two GacIdentityPermissions failed." ); return false; } } catch ( Exception^ e ) { Console::WriteLine( "An exception was thrown : {0}", e ); return false; } return true; }
// Union creates a new permission that is the union of the current // permission and the specified permission. private boolean UnionDemo() { GacIdentityPermission gac1 = new GacIdentityPermission( PermissionState.None); GacIdentityPermission gac2 = new GacIdentityPermission(); try { GacIdentityPermission p3 = ((GacIdentityPermission)(gac1.Union(gac2))); if (p3 != null) { Console.WriteLine("The union of two GacIdentityPermissions " + "was successful."); } else { Console.WriteLine("The union of two " + "GacIdentityPermissions failed."); return false; } } catch (System.Exception e) { Console.WriteLine(("An exception was thrown : " + e)); return false; } return true; } //UnionDemo
Windows 98, Windows 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
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
参照
- GacIdentityPermission.Union メソッドのページへのリンク