WebPermission.ToXml Méthode
Définition
Important
Certaines informations portent sur la préversion du produit qui est susceptible d’être en grande partie modifiée avant sa publication. Microsoft exclut toute garantie, expresse ou implicite, concernant les informations fournies ici.
Crée un encodage XML d'un WebPermission et son état actuel.
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
Retours
SecurityElement qui contient une représentation encodée XML de WebPermission incluant notamment des informations d'état.
Exemples
L’exemple suivant montre comment créer ToXml un System.Security.SecurityElement et imprimer ses attributs sur la 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())
Remarques
Utilisez la FromXml méthode pour restaurer les informations d’état à partir d’un SecurityElement.