WebPermission.FromXml(SecurityElement) Metodo

Definizione

Ricostruisce una WebPermission da una codifica XML.Reconstructs a WebPermission from an XML encoding.

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)

Parametri

securityElement
SecurityElement

La codifica XML dalla quale ricostruire la WebPermission.The XML encoding from which to reconstruct the WebPermission.

Eccezioni

Il parametro securityElement è null..The securityElement parameter is null.

securityElement non è un elemento di autorizzazione per questo tipo.securityElement is not a permission element for this type.

Esempio

Nell'esempio seguente viene creato un System.Security.SecurityElement, viene popolato gli attributi e vengono utilizzati FromXml per trasferire tali informazioni a un'istanza di WebPermission.The following example creates a System.Security.SecurityElement, populates its attributes, and uses FromXml to transfer this information to an instance of 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())

Commenti

Il metodo FromXml ricostruisce una WebPermission da una codifica XML definita dalla classe SecurityElement.The FromXml method reconstructs a WebPermission from an XML encoding that is defined by the SecurityElement class.

Usare il metodo ToXml per codificare in XML il WebPermission, incluse le informazioni sullo stato.Use the ToXml method to XML-encode the WebPermission, including state information.

Si applica a

Vedi anche