SiteIdentityPermission.Intersect メソッド
アセンブリ: mscorlib (mscorlib.dll 内)

Dim instance As SiteIdentityPermission Dim target As IPermission Dim returnValue As IPermission returnValue = instance.Intersect(target)
戻り値
現在のアクセス許可と指定したアクセス許可の積集合を表す新しいアクセス許可。積集合が空の場合、この新しいアクセス許可は null 参照 (Visual Basic では Nothing) です。


2 つのアクセス許可の積集合となるアクセス許可には、両方に共通するサイトが記述されています。2 つのアクセス許可を要求し、その両方について要求が満たされる場合にだけ、それらの積集合を表すアクセス許可に対する要求も満たされます。たとえば、www.fourthcoffee.com へのアクセス権を表すアクセス許可と、*.fourthcoffee.com へのアクセス権を表すアクセス許可の積集合は、www.fourthcoffee.com へのアクセス権を表すアクセス許可になります。
2 つの同じサイト ID アクセス許可の積集合は、同じアクセス許可です。2 つの異なる (ワイルドカード以外の) 式の積集合は、空のアクセス許可です。ワイルドカード式と一致するサイトの積集合は、そのサイトです。一致する 2 つのワイルドカード式の積集合は、2 つの式のうち、より長く、より固有な方の式です。

次に示すのは、Intersect メソッドを使用した場合の結果を示す例です (メソッドの使用方法を示すものではありません)。ここに示すコードは、より長いコードの一部です。よりよく理解するためには、コード全体を記述して実行し、その出力を確認することをお勧めします。完全なコードについては、SiteIdentityPermission クラスを参照してください。
' Intersect creates and returns a new permission that is the intersection of the ' current permission and the permission specified. Private Function IntersectDemo() As Boolean Dim returnCodeCode As Boolean = True Dim site1 As [String] = "" Dim site2 As [String] = "" Dim siteIdPerm1, siteIdPerm2, p3 As SiteIdentityPermission Dim siteGen1 As New SiteGenerator() Dim siteGen2 As New SiteGenerator() siteGen1.ResetIndex() While siteGen1.CreateSite(site1) siteIdPerm1 = siteGen1.CreatePerm(site1) If siteIdPerm1 Is Nothing Then GoTo ContinueWhile1 End If siteGen2.ResetIndex() Console.WriteLine("**************************************************************************") While siteGen2.CreateSite(site2) siteIdPerm2 = siteGen2.CreatePerm(site2) If siteIdPerm2 Is Nothing Then GoTo ContinueWhile2 End If Dim firstSite As [String] = IIf(site1 Is Nothing, "null", site1) Dim secondSite As [String] = IIf(site2 Is Nothing, "null", site2) Try p3 = CType(siteIdPerm1.Intersect(siteIdPerm2), SiteIdentityPermission) Dim thirdSite As [String] = IIf(p3.Site Is Nothing, "null", p3.Site.ToString()) If Not (p3 Is Nothing) Then Console.WriteLine(("The intersection of " & firstSite & " and " & ControlChars.Lf & ControlChars.Tab & secondSite & " = " & thirdSite & ControlChars.Lf)) Else Console.WriteLine(("The intersection of " & firstSite & " and " & ControlChars.Lf & ControlChars.Tab & secondSite & " = null." & ControlChars.Lf)) End If Catch Console.WriteLine(("The intersection of " & firstSite & " and " & ControlChars.Lf & ControlChars.Tab & secondSite & " = null." & ControlChars.Lf)) End Try ContinueWhile2: End While ContinueWhile1: End While Return returnCodeCode End Function 'IntersectDemo
// Intersect creates and returns a new permission that is the intersection of the // current permission and the permission specified. private bool IntersectDemo() { bool returnCodeCode = true; String site1, site2; SiteIdentityPermission siteIdPerm1, siteIdPerm2, p3; SiteGenerator siteGen1 = new SiteGenerator(); SiteGenerator siteGen2 = new SiteGenerator(); siteGen1.ResetIndex(); while (siteGen1.CreateSite(out site1)) { siteIdPerm1 = siteGen1.CreatePerm(site1); if (siteIdPerm1 == null ) continue; siteGen2.ResetIndex(); Console.WriteLine("**************************************************************************"); while (siteGen2.CreateSite(out site2)) { siteIdPerm2 = siteGen2.CreatePerm(site2); if (siteIdPerm2 == null ) continue; String firstSite = site1 == null ? "null" : site1; String secondSite = site2 == null ? "null" : site2; try { p3 = (SiteIdentityPermission)siteIdPerm1.Intersect(siteIdPerm2); String thirdSite = p3.Site == null ? "null" : p3.Site; if (p3 != null) { Console.WriteLine("The intersection of " + firstSite + " and \n\t" + secondSite + " = " + thirdSite + "\n"); } else { Console.WriteLine("The intersection of " + firstSite + " and \n\t" + secondSite + " = null.\n"); } } catch { Console.WriteLine("The intersection of " + firstSite + " and \n\t" + secondSite + " = null.\n"); } } } return returnCodeCode; }
// Intersect creates and returns a new permission that is the intersection of the // current permission and the permission specified. bool IntersectDemo() { bool returnCodeCode = true; String^ site1; String^ site2; SiteIdentityPermission^ siteIdPerm1; SiteIdentityPermission^ siteIdPerm2; SiteIdentityPermission^ p3; SiteGenerator^ siteGen1 = gcnew SiteGenerator; SiteGenerator^ siteGen2 = gcnew SiteGenerator; siteGen1->ResetIndex(); while ( siteGen1->CreateSite( &site1 ) ) { siteIdPerm1 = siteGen1->CreatePerm(&site1); if ( siteIdPerm1 == nullptr ) continue; siteGen2->ResetIndex(); Console::WriteLine( "**************************************************************************" ); while ( siteGen2->CreateSite( &site2 ) ) { siteIdPerm2 = siteGen2->CreatePerm(&site2); if ( siteIdPerm2 == nullptr ) continue; String^ firstSite = site1 == nullptr ? "0" : site1; String^ secondSite = site2 == nullptr ? "0" : site2; try { p3 = dynamic_cast<SiteIdentityPermission^>(siteIdPerm1->Intersect( siteIdPerm2 )); String^ thirdSite = p3->Site == nullptr ? "0" : p3->Site; if ( p3 != nullptr ) { Console::WriteLine( "The intersection of {0} and \n\t{1} = {2}\n", firstSite, secondSite, thirdSite ); } else { Console::WriteLine( "The intersection of {0} and \n\t{1} = null.\n", firstSite, secondSite ); } } catch ( Exception^ ) { Console::WriteLine( "The intersection of {0} and \n\t{1} = null.\n", firstSite, secondSite ); } } } return returnCodeCode; }
// Intersect creates and returns a new permission that is the intersection // of the current permission and the permission specified. private boolean IntersectDemo() { boolean returnCodeCode = true; String site1[] = new String[1]; String site2[] = new String[1]; boolean successFlag[] = new boolean[1]; SiteIdentityPermission siteIdPerm1[] = new SiteIdentityPermission[1]; SiteIdentityPermission siteIdPerm2[] = new SiteIdentityPermission[1]; SiteIdentityPermission p3 = null; SiteGenerator siteGen1 = new SiteGenerator(); SiteGenerator siteGen2 = new SiteGenerator(); siteGen1.ResetIndex(); while(siteGen1.CreateSite(siteIdPerm1, site1, successFlag)) { if (siteIdPerm1 == null | successFlag[0] == false) { continue ; } siteGen2.ResetIndex(); Console.WriteLine("***************************************" + "***********************************"); while(siteGen2.CreateSite(siteIdPerm2, site2, successFlag)) { if (siteIdPerm2[0] == null | successFlag[0] == false) { continue ; } String firstSite = (site1[0] == null) ? "null" : site1[0]; String secondSite = (site2[0] == null) ? "null" : site2[0]; try { p3 =((SiteIdentityPermission)(siteIdPerm1[0]. Intersect(siteIdPerm2[0]))); String thirdSite = (p3.get_Site() == null) ? "null" : p3.get_Site(); if (p3 != null) { Console.WriteLine(("The intersection of " + firstSite + " and \n\t" + secondSite + " = " + thirdSite + "\n")); } else { Console.WriteLine(("The intersection of " + firstSite + " and \n\t" + secondSite + " = null.\n")); } } catch(Exception exp) { Console.WriteLine(("The intersection of " + firstSite + " and \n\t" + secondSite + " = null.\n")); } } } return returnCodeCode ; } //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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


- SiteIdentityPermission.Intersect メソッドのページへのリンク