WebPermission.ToXml 메서드

정의

WebPermission 및 현재 상태의 XML 인코딩을 만듭니다.Creates an XML encoding of a WebPermission and its current state.

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

반환

SecurityElement

상태 정보를 포함하여 SecurityElement의 XML 인코딩 표현이 들어 있는 WebPermission입니다.A SecurityElement that contains an XML-encoded representation of the WebPermission, including state information.

예제

다음 예제에서는를 사용 하 여 ToXml 을 만들고 System.Security.SecurityElement 해당 특성을 콘솔에 출력 하는 방법을 보여 줍니다.The following example demonstrates how to use ToXml to create a System.Security.SecurityElement and print its attributes to the console.

// 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())

설명

FromXml에서 상태 정보를 복원 하려면 메서드를 사용 SecurityElement 합니다.Use the FromXml method to restore the state information from a SecurityElement.

적용 대상

추가 정보