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

Dim instance As SiteIdentityPermission Dim target As IPermission Dim returnValue As IPermission returnValue = instance.Union(target)
戻り値
現在のアクセス許可と指定したアクセス許可の和集合を表す新しいアクセス許可。


Union を呼び出すと、現在のアクセス許可と指定したアクセス許可の両方が表すサイトをすべて表すアクセス許可が作成されます。いずれかのアクセス許可を要求し、その要求が満たされた場合、両者の和集合を表すアクセス許可に対する要求も満たされます。たとえば、www.fourthcoffee.com へのアクセス権を表すアクセス許可と、*.fourthcoffee.com へのアクセス権を表すアクセス許可の和集合は、*.fourthcoffee.com へのアクセス権を表すアクセス許可になります。
アクセス許可と null 参照 (Visual Basic では Nothing) の和集合では、アクセス許可は null 参照 (Visual Basic では Nothing) にはなりません。アクセス許可とそのアクセス許可のサブセットの和集合では、アクセス許可にサブセットが含まれます。その他の組み合わせでは、ArgumentException がスローされます。たとえば、サイト ID www.fourthcoffee.com とサイト ID www.tailspintoys.com の和集合は、どちらも他方のサブセットではないため、例外になります。

次に示すのは、Union メソッドを使用した場合の結果を示す例です (メソッドの使用方法を示すものではありません)。ここに示すコードは、より長いコードの一部です。よりよく理解するためには、コード全体を記述して実行し、その出力を確認することをお勧めします。完全なコードについては、SiteIdentityPermission クラスを参照してください。
' Union creates a new permission that is the union of the current permission ' and the specified permission. Private Function UnionDemo() 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.Union(siteIdPerm2), SiteIdentityPermission) Dim thirdSite As [String] = IIf(p3.Site Is Nothing, "null", p3.Site.ToString()) If Not (p3 Is Nothing) Then Console.WriteLine(("The union of " & firstSite & " and " & ControlChars.Lf & ControlChars.Tab & secondSite & " = " & ControlChars.Lf & ControlChars.Tab & thirdSite & ControlChars.Lf)) Else Console.WriteLine(("The union of " & firstSite & " and " & ControlChars.Lf & ControlChars.Tab & secondSite & " = null." & ControlChars.Lf)) End If Catch e As Exception ' Expected exception, result of the union is null. Console.WriteLine((e.Message & firstSite & " and " & ControlChars.Lf & ControlChars.Tab & secondSite & ControlChars.Lf)) End Try ContinueWhile2: End While ContinueWhile1: End While Return returnCodeCode End Function 'UnionDemo
// Union creates a new permission that is the union of the current permission // and the specified permission. private bool UnionDemo() { 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.Union(siteIdPerm2); String thirdSite = p3.Site == null ? "null" : p3.Site; if (p3 != null) { Console.WriteLine("The union of " + firstSite + " and \n\t" + secondSite + " = \n\t" + thirdSite + "\n"); } else { Console.WriteLine("The union of " + firstSite + " and \n\t" + secondSite + " = null.\n"); } } catch (Exception e) { // Expected exception. Console.WriteLine(e.Message + "\n\t" + firstSite + " and " + secondSite + "\n"); } } } return returnCodeCode; }
// Union creates a new permission that is the union of the current permission // and the specified permission. bool UnionDemo() { 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 ? "null" : site1; String^ secondSite = site2 == nullptr ? "null" : site2; try { p3 = dynamic_cast<SiteIdentityPermission^>(siteIdPerm1->Union( siteIdPerm2 )); String^ thirdSite = p3->Site == nullptr ? "null" : p3->Site; if ( p3 != nullptr ) { Console::WriteLine( "The union of {0} and \n\t{1} = \n\t{2}\n", firstSite, secondSite, thirdSite ); } else { Console::WriteLine( "The union of {0} and \n\t{1} = null.\n", firstSite, secondSite ); } } catch ( Exception^ ) { // Expected exception, result of the union is 0. Console::WriteLine( "The union of {0} and \n\t{1} = null.\n", firstSite, secondSite ); } } } return returnCodeCode; }
// Union creates a new permission that is the union of the current // permission // and the specified permission. private boolean UnionDemo() { 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[0] == 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].Union(siteIdPerm2[0]))); String thirdSite = (p3.get_Site() == null) ? "null" : p3.get_Site(); if (p3 != null) { Console.WriteLine(("The union of " + firstSite + " and \n\t" + secondSite + " = \n\t" + thirdSite + "\n")); } else { Console.WriteLine(("The union of " + firstSite + " and \n\t" + secondSite + " = null.\n")); } } catch(Exception exp) { // Expected exception, result of the union is null. Console.WriteLine(("The union of " + firstSite + " and \n\t" + secondSite + " = null.\n")); } } } return returnCodeCode ; }

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.Union メソッドのページへのリンク