DataProtectionPermission.FromXml(SecurityElement) 方法

定义

从 XML 编码重新构造具有特定状态的权限。Reconstructs a permission with a specific state from an XML encoding.

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

参数

securityElemente
SecurityElement

一个 SecurityElement,其中包含用于重新构造权限的 XML 编码。A SecurityElement that contains the XML encoding used to reconstruct the permission.

异常

securityElementnullsecurityElement is null.

securityElement 不是有效的权限元素。securityElement is not a valid permission element.

- 或 --or- 不支持 securityElement 的版本号。The version number of securityElement is not supported.

示例

下面的代码示例演示如何使用 FromXml 方法。The following code example shows the use of the FromXml method. 此代码示例是为 DataProtectionPermission 类提供的更大示例的一部分。This code example is part of a larger example provided for the DataProtectionPermission class.

备注

此代码示例旨在显示方法的行为,而不是演示方法的用法。The code example is intended to show the behavior of the method, not to demonstrate its use. 通常,权限类的方法由安全基础结构使用;它们通常不在应用程序中使用。In general, the methods of permission classes are used by the security infrastructure; they are not typically used in applications.

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 对象。The FromXml method reconstructs a DataProtectionPermission object from an XML encoding defined by the SecurityElement class. 使用 ToXml 方法对 DataProtectionPermission(包括状态信息)进行 XML 编码。Use the ToXml method to XML-encode the DataProtectionPermission, including state information.

适用于