Share via


DataProtectionPermission.ToXml 方法

定义

创建权限及其当前状态的 XML 编码。

public:
 override System::Security::SecurityElement ^ ToXml();
public override System.Security.SecurityElement ToXml ();
override this.ToXml : unit -> System.Security.SecurityElement
Public Overrides Function ToXml () As SecurityElement

返回

权限及状态信息的 XML 编码。

示例

下面的代码示例演示如何使用 ToXml 方法。 此代码示例是为 DataProtectionPermission 类提供的一个更大示例的一部分。

注意

代码示例旨在显示方法的行为,而不是演示其用法。 通常,权限类的方法由安全基础结构使用;它们通常不用于应用程序。

Console::WriteLine( "Using an XML round trip to reset the fourth "
"permission." );
sp4->FromXml( sp2->ToXml() );
rc = sp4->Equals( sp2 );
Console::WriteLine( "Does the XML round trip result equal the "
"original permission? {0}", (rc ? (String^)"Yes" : "No") );
Console.WriteLine("Using an XML round trip to reset the fourth " +
    "permission.");
sp4.FromXml(sp2.ToXml());
rc = sp4.Equals(sp2);
Console.WriteLine("Does the XML round trip result equal the " +
    "original permission? " + (rc ? "Yes" : "No"));
    Console.WriteLine("Using an XML round trip to reset the fourth " + "permission.")
    sp4.FromXml(sp2.ToXml())
    rc = sp4.Equals(sp2)
    Console.WriteLine("Does the XML round trip result equal the " + "original permission? " + IIf(rc, "Yes", "No")) 'TODO: For performance reasons this should be changed to nested IF statements

End Sub

注解

FromXml使用 方法从 SecurityElement还原状态信息。

适用于