DataProtectionPermission.FromXml(SecurityElement) 方法

定义

从 XML 编码重新构造具有特定状态的权限。

public:
 override void FromXml(System::Security::SecurityElement ^ securityElement);
public override void FromXml (System.Security.SecurityElement securityElement);
override this.FromXml : System.Security.SecurityElement -> unit
Public Overrides Sub FromXml (securityElement As SecurityElement)

参数

securityElement
SecurityElement

一个 SecurityElement,其中包含用于重新构造权限的 XML 编码。

例外

securityElementnull

securityElement 不是有效的权限元素。

- 或 -

不支持 securityElement 的版本号。

示例

下面的代码示例演示如何使用 FromXml 方法。 此代码示例是为 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 类定义的 XML 编码重新构造 DataProtectionPermission 对象。 ToXml使用 方法对 进行 XML 编码,DataProtectionPermission包括状态信息。

适用于