다음을 통해 공유


WebPermission.ToXml 메서드

정의

WebPermission 및 현재 상태의 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

반환

상태 정보를 포함하여 SecurityElement의 XML 인코딩 표현이 들어 있는 WebPermission입니다.

예제

다음 예제에서는 를 사용하여 ToXml 을 만들고 System.Security.SecurityElement 해당 특성을 콘솔에 출력하는 방법을 보여 줍니다.

// 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.

적용 대상

추가 정보