Description





Description

The XML encoding of a WebPermission instance is defined below in EBNF format. The following conventions are used:

  • All non-literals in the grammar below are shown in normal type.

  • All literals are in bold font.

The following meta-language symbols are used:

  • "*" represents a meta-language symbol suffixing an expression that can appear zero or more times.

  • "?" represents a meta-language symbol suffixing an expression that can appear zero or one time.

  • "+" represents a meta-language symbol suffixing an expression that can appear one or more times.

  • "(',')" is used to group literals, non-literals, or a mixture of literals and non-literals.

  • "|" denotes an exclusive disjunction between two expressions.

  • ":= " denotes a production rule where a left-hand non-literal is replaced by a right-hand expression containing literals, non-literals, or both.

BuildVersion refers to the build version of the shipping CLI. This is a dotted build number such as "2412.0".

ECMAPubKeyToken::= b77a5c561934e089

HostName refers to a host name such as "www.contoso.com".

Portnumber denotes a System.Int32 value indicating a port.

TransportProtocol::= 1 | 2 | 3 /*1= UDP, 2 = TCP, 3 = both */


WebPermissionXML::=

<IPermission

class="

System.Net.WebPermission,

System,

Version=1.0.BuildVersion,

Culture=neutral,

PublicKeyToken=ECMAPubKeyToken"

version="1"

(

Unrestricted="true"/>

)

|

>

(<ConnectAccess>

(

<URI>HostName#PortNumber#TransportProtocol</URI>

)+

</ConnectAccess>

</IPermission>

)

|

>

(<AcceptAccess>

(

<URI>HostName#PortNumber#TransportProtocol</URI>

)+

</AcceptAccess>

</IPermission>

)

|

/>


Example

using System;

using System.Net;

using System.Security;

using System.Security.Permissions;



public class WebPermissionSample

{

    public static void Main()

    {

        WebPermission perm = new

            WebPermission(PermissionState.Unrestricted);

        Console.WriteLine("XML encoding of WebPermission:");

        SecurityElement sec = perm.ToXml();

        Console.WriteLine(sec);



        WebPermission permCopy = (WebPermission)perm.Copy();

        Console.WriteLine("XML encoding of copy of WebPermission:");

        sec = permCopy.ToXml();

        Console.WriteLine(sec);



        Boolean result = perm.IsSubsetOf(permCopy);

        Console.WriteLine("Initial WebPermission instance "

            + "IsSubsetOf copied instance: {0}",

            result);

        Console.WriteLine();

        Console.WriteLine();

        Console.WriteLine("Press Enter to continue");

        Console.ReadLine();

    }

}




The output is


XML encoding of WebPermission:

<IPermission class="System.Net.WebPermission, System, Version=1.0.5000.0, Culture=neutral,

 PublicKeyToken=b77a5c561934e089"

             version="1"

             Unrestricted="true"/>



XML encoding of copy of WebPermission:

<IPermission class="System.Net.WebPermission, System, Version=1.0.5000.0, Culture=neutral,

 PublicKeyToken=b77a5c561934e089"

             version="1"

             Unrestricted="true"/>



Initial WebPermission instance IsSubsetOf copied instance: True





Press Enter to continue



     Python   SQL   Java   php   Perl 
     game development   web development   internet   *nix   graphics   hardware 
     telecommunications   C++ 
     Flash   Active Directory   Windows