GacIdentityPermission.ToXml メソッド
アセンブリ: mscorlib (mscorlib.dll 内)
構文
Dim instance As GacIdentityPermission Dim returnValue As SecurityElement returnValue = instance.ToXml
ステータス情報を含むアクセス許可の XML エンコーディングを表す SecurityElement。
使用例
ToXml メソッドを使用するコード例を次に示します。このコード例は、GacIdentityPermission クラスのトピックで取り上げているコード例の一部分です。
' ToXml creates an XML encoding of the permission and its current state; FromXml reconstructs a ' permission with the specified state from the XML encoding. Private Function ToFromXmlDemo() As Boolean Dim Gac1 As New GacIdentityPermission Dim Gac2 As New GacIdentityPermission Console.WriteLine("**************************************************************************") Try Gac2 = New GacIdentityPermission(PermissionState.None) Gac2.FromXml(Gac1.ToXml()) Dim result As Boolean = Gac2.Equals(Gac1) If Gac2.IsSubsetOf(Gac1) AndAlso Gac1.IsSubsetOf(Gac2) Then Console.WriteLine(("Result of ToFromXml = " & Gac2.ToString())) Else Console.WriteLine(Gac2.ToString()) Console.WriteLine(Gac1.ToString()) Return False End If Catch e As Exception Console.WriteLine(("ToFromXml failed. " & e.ToString())) Return False End Try Return True End Function 'ToFromXmlDemo
// ToXml creates an XML encoding of the permission and its current state; FromXml reconstructs a // permission with the specified state from the XML encoding. private bool ToFromXmlDemo() { GacIdentityPermission Gac1 = new GacIdentityPermission(); GacIdentityPermission Gac2 = new GacIdentityPermission(); Console.WriteLine("**************************************************************************"); try { Gac2 = new GacIdentityPermission(PermissionState.None); Gac2.FromXml(Gac1.ToXml()); bool result = Gac2.Equals(Gac1); if (Gac2.IsSubsetOf(Gac1) && Gac1.IsSubsetOf(Gac2)) { Console.WriteLine("Result of ToFromXml = " + Gac2.ToString()); } else { Console.WriteLine(Gac2.ToString()); Console.WriteLine(Gac1.ToString()); return false; } } catch (Exception e) { Console.WriteLine("ToFromXml failed. " + e); return false; } return true; }
// ToXml creates an XML encoding of the permission and its current state; FromXml reconstructs a // permission with the specified state from the XML encoding. bool ToFromXmlDemo() { GacIdentityPermission ^ Gac1 = gcnew GacIdentityPermission; GacIdentityPermission ^ Gac2 = gcnew GacIdentityPermission; Console::WriteLine( "**************************************************************************" ); try { Gac2 = gcnew GacIdentityPermission( PermissionState::None ); Gac2->FromXml( Gac1->ToXml() ); bool result = Gac2->Equals( Gac1 ); if ( Gac2->IsSubsetOf( Gac1 ) && Gac1->IsSubsetOf( Gac2 ) ) { Console::WriteLine( "Result of ToFromXml = {0}", Gac2 ); } else { Console::WriteLine( Gac2 ); Console::WriteLine( Gac1 ); return false; } } catch ( Exception^ e ) { Console::WriteLine( "ToFromXml failed. {0}", e ); return false; } return true; } public:
// ToXml creates an XML encoding of the permission and its current state; // FromXml reconstructs a permission with the specified state from the // XML encoding. private boolean ToFromXmlDemo() { GacIdentityPermission gac1 = new GacIdentityPermission(); GacIdentityPermission gac2 = new GacIdentityPermission(); Console.WriteLine("***************************************" + "***********************************"); try { gac2 = new GacIdentityPermission(PermissionState.None); gac2.FromXml(gac1.ToXml()); boolean result = gac2.Equals(gac1); if (gac2.IsSubsetOf(gac1) && gac1.IsSubsetOf(gac2)) { Console.WriteLine(("Result of ToFromXml = " + gac2.ToString())); } else { Console.WriteLine(gac2.ToString()); Console.WriteLine(gac1.ToString()); return false; } } catch (System.Exception e) { Console.WriteLine(("ToFromXml failed. " + e)); return false; } return true; } //ToFromXmlDemo
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.ToXml メソッドのページへのリンク