共用方式為


WebPermission.FromXml(SecurityElement) 方法

定義

從 XML 編碼方式重建 WebPermission

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

要重建 WebPermission 的 XML 編碼方式。

例外狀況

securityElement 參數為 null

securityElement 不是這個型別的使用權限項目。

範例

下列範例會 System.Security.SecurityElement建立 、填入其屬性,並使用 FromXml 將這項資訊傳送至的 WebPermission實例。

// Create  a WebPermission without permission on the protected resource
WebPermission^ myWebPermission1 = gcnew WebPermission( PermissionState::None );

// Create a SecurityElement by calling the ToXml method on the WebPermission
// instance and display its attributes (which hold the XML encoding of
// the WebPermission).
Console::WriteLine( "Attributes and Values of the WebPermission are:" );
myWebPermission1->ToXml();

// Create another WebPermission with no permission on the protected resource
WebPermission^ myWebPermission2 = gcnew WebPermission( PermissionState::None );

//Converts the new WebPermission from XML using myWebPermission1.
myWebPermission2->FromXml( myWebPermission1->ToXml() );

// Create  a WebPermission without permission on the protected resource.
WebPermission myWebPermission1 = new WebPermission(PermissionState.None);

// Create a SecurityElement by calling the ToXml method on the WebPermission 
// instance and display its attributes (which hold the XML encoding of 
// the WebPermission).
Console.WriteLine("Attributes and Values of the WebPermission are :");
myWebPermission1.ToXml().ToString();

// Create another WebPermission with no permission on the protected resource.
WebPermission myWebPermission2 = new WebPermission(PermissionState.None);

//Converts the new WebPermission from XML using myWebPermission1.
myWebPermission2.FromXml(myWebPermission1.ToXml());
' Create  a WebPermission without permission on the protected resource.
Dim myWebPermission1 As New WebPermission(PermissionState.None)

' Create a SecurityElement by calling the ToXml method on the WebPermission 
' instance and display its attributes (which hold the XML encoding of 
' the WebPermission).
Console.WriteLine("Attributes and Values of the WebPermission are :")
myWebPermission1.ToXml().ToString()

' Create another WebPermission with no permission on the protected resource.
Dim myWebPermission2 As New WebPermission(PermissionState.None)

'Converts the new WebPermission from XML using myWebPermission1.
myWebPermission2.FromXml(myWebPermission1.ToXml())

備註

方法 FromXmlWebPermission 從 類別所 SecurityElement 定義的 XML 編碼重新建構 。

ToXml使用 方法來 XML 編碼 WebPermission,包括狀態資訊。

適用於

另請參閱