Export (0) Print
Expand All

WebPermission.FromXml Method

Reconstructs a WebPermission from an XML encoding.

[Visual Basic]
Overrides Public Sub FromXml( _
   ByVal securityElement As SecurityElement _
) Implements ISecurityEncodable.FromXml
[C#]
public override void FromXml(
 SecurityElement securityElement
);
[C++]
public: void FromXml(
 SecurityElement* securityElement
);
[JScript]
public override function FromXml(
   securityElement : SecurityElement
);

Parameters

securityElement
The XML encoding from which to reconstruct the WebPermission.

Implements

ISecurityEncodable.FromXml

Exceptions

Exception Type Condition
ArgumentNullException The securityElement parameter is a null reference (Nothing in Visual Basic)
ArgumentException securityElement is not a permission element for this type.

Remarks

The FromXml method reconstructs a WebPermission from an XML encoding defined by the SecurityElement class.

Use the ToXml method to XML-encode the WebPermission, including state information.

Example

[Visual Basic, C#, C++] The following example creates a System.Security.SecurityElement, populates its attributes, and uses FromXml to transfer this information to an instance of WebPermission.

[Visual Basic] 
' 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())


[C#] 

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


[C++] 
// 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(S"Attributes and Values of the WebPermission are :");
myWebPermission1->ToXml();

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

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, Common Language Infrastructure (CLI) Standard

See Also

WebPermission Class | WebPermission Members | System.Net Namespace | ToXml

Show:
© 2014 Microsoft