GacIdentityPermission.Intersect メソッド
アセンブリ: mscorlib (mscorlib.dll 内)
構文
Dim instance As GacIdentityPermission Dim target As IPermission Dim returnValue As IPermission returnValue = instance.Intersect(target)
戻り値
現在のアクセス許可と指定したアクセス許可の積集合を表す新しいアクセス許可。積集合が空の場合、新しいアクセス許可は null 参照 (Visual Basic では Nothing) です。
解説
2 つのアクセス許可の積集合となるアクセス許可には、両方に共通する操作の集合が記述されています。2 つのアクセス許可を要求し、その両方について要求が満たされる場合にだけ、それらの積集合を表すアクセス許可に対する要求も満たされます。
現在のアクセス許可が、指定したアクセス許可と等しい場合、GacIdentityPermission は設定操作 (IsSubsetOf、Intersect、および Union の各メソッド) だけをサポートします。
Intersect メソッドを使用するコード例を次に示します。このコード例は、GacIdentityPermission クラスのトピックで取り上げているコード例の一部分です。
' Intersect creates and returns a new permission that is the intersection of the ' current permission and the specified permission. Private Function IntersectDemo() As Boolean Dim Gac1 As New GacIdentityPermission Dim Gac2 As New GacIdentityPermission Try Dim p3 As GacIdentityPermission = CType(Gac1.Intersect(Gac2), GacIdentityPermission) If Not (p3 Is Nothing) Then Console.WriteLine(("The intersection of the two permissions = " & p3.ToString() & ControlChars.Lf)) Else Console.WriteLine("The intersection of the two permissions is null." & ControlChars.Lf) End If Catch e As Exception Console.WriteLine(("An exception was thrown : " & e.ToString())) Return False End Try Return True End Function 'IntersectDemo
// Intersect creates and returns a new permission that is the intersection of the // current permission and the specified permission. private bool IntersectDemo() { GacIdentityPermission Gac1 = new GacIdentityPermission(); GacIdentityPermission Gac2 = new GacIdentityPermission(); try { GacIdentityPermission p3 = (GacIdentityPermission)Gac1.Intersect(Gac2); if (p3 != null) { Console.WriteLine("The intersection of the two permissions = " + p3.ToString() + "\n"); } else { Console.WriteLine("The intersection of the two permissions is null.\n"); } } catch (Exception e) { Console.WriteLine("An exception was thrown : " + e); return false; } return true; }
// Intersect creates and returns a new permission that is the intersection of the // current permission and the specified permission. bool IntersectDemo() { GacIdentityPermission ^ Gac1 = gcnew GacIdentityPermission; GacIdentityPermission ^ Gac2 = gcnew GacIdentityPermission; try { GacIdentityPermission ^ p3 = dynamic_cast<GacIdentityPermission^>(Gac1->Intersect( Gac2 )); if ( p3 != nullptr ) { Console::WriteLine( "The intersection of the two permissions = {0}\n", p3 ); } else { Console::WriteLine( "The intersection of the two permissions is null.\n" ); } } catch ( Exception^ e ) { Console::WriteLine( "An exception was thrown : {0}", e ); return false; } return true; }
// Intersect creates and returns a new permission that is the // intersection of the current permission and the specified permission. private boolean IntersectDemo() { GacIdentityPermission gac1 = new GacIdentityPermission(); GacIdentityPermission gac2 = new GacIdentityPermission(); try { GacIdentityPermission p3 = ((GacIdentityPermission)(gac1.Intersect(gac2))); if (p3 != null) { Console.WriteLine(("The intersection of the two permissions = " + p3.ToString() + "\n")); } else { Console.WriteLine("The intersection of the two permissions " + "is null.\n"); } } catch (System.Exception e) { Console.WriteLine(("An exception was thrown : " + e)); return false; } return true; } //IntersectDemo
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.Intersect メソッドのページへのリンク