Description





Description

The XML encoding of a DnsPermission 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

DnsPermissionXML::=

<IPermission

class="

System.Net.DnsPermission,

System,

Version=1.0.BuildVersion,

Culture=neutral,

PublicKeyToken=ECMAPubKeyToken"

version="1"

(

Unrestricted="true"/>

)

|

/>


Example



using System;

using System.Net;

using System.Security.Permissions;



public class DnsPermissionSample

{

    public static void Main()

    {

        DnsPermission unrestricted1 = new

            DnsPermission(PermissionState.Unrestricted);

        DnsPermission unrestricted2 = new

            DnsPermission(PermissionState.Unrestricted);

        DnsPermission restricted1 = new

            DnsPermission(PermissionState.None);

        DnsPermission restricted2 = new

            DnsPermission(PermissionState.None);



        DnsPermission result =

            (DnsPermission)restricted1.Union(restricted2);

        ShowResult(result, "Union of restricted and "

            + "restricted DnsPermission instances:");

        result = (DnsPermission)unrestricted1.Union(restricted1);

        ShowResult(result, "Union of un-restricted and "

            + "restricted DnsPermission instances:");

        result = (DnsPermission)unrestricted1.Union(unrestricted2);

        ShowResult(result, "Union of un-restricted and "

            + "un-restricted DnsPermission instances:");

        result = (DnsPermission)unrestricted1.Union(null);

        ShowResult(result, "Union of un-restricted and "

            + "null DnsPermission instances:");

        result = (DnsPermission)unrestricted1.Intersect(restricted1);

        ShowResult(result, "Intersect of un-restricted and "

            + "restricted DnsPermission instances:");

        result = (DnsPermission)unrestricted1.Intersect(unrestricted2);

        ShowResult(result, "Intersect of un-restricted and "

            + "un-restricted DnsPermission instances:");



        Boolean subset = unrestricted1.IsSubsetOf(restricted1);

        Console.WriteLine("\nUn-restricted DnsPermission instance "

            + "IsSubsetOf restricted instance: {0}",

            subset);

        subset = unrestricted1.IsSubsetOf(unrestricted2);

        Console.WriteLine("Un-restricted DnsPermission instance "

            + "IsSubsetOf un-restricted instance: {0}",

            subset);

        subset = restricted1.IsSubsetOf(unrestricted1);

        Console.WriteLine("Restricted DnsPermission instance "

            + "IsSubsetOf un-restricted instance: {0}",

            subset);

        subset = restricted1.IsSubsetOf(restricted2);

        Console.WriteLine("Restricted DnsPermission instance "

            + "IsSubsetOf restricted instance: {0}",

            subset);

        Console.WriteLine();

        Console.WriteLine();

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

        Console.ReadLine();

    }



    private static void ShowResult(DnsPermission result,

        String caption)

    {

        Console.WriteLine();

        Console.WriteLine(caption);

        if (result == null)

        {

            Console.WriteLine("<null>");

        }

        else

        {

            Console.WriteLine("DnsPermission.IsUnrestricted = {0}",

                result.IsUnrestricted());

        }

    }



}


The output is


Union of restricted and restricted DnsPermission instances:

DnsPermission.IsUnrestricted = False



Union of un-restricted and restricted DnsPermission instances:

DnsPermission.IsUnrestricted = True



Union of un-restricted and un-restricted DnsPermission instances:

DnsPermission.IsUnrestricted = True



Union of un-restricted and null DnsPermission instances:

DnsPermission.IsUnrestricted = True



Intersect of un-restricted and restricted DnsPermission instances:

<null>



Intersect of un-restricted and un-restricted DnsPermission instances:

DnsPermission.IsUnrestricted = True



Un-restricted DnsPermission instance IsSubsetOf restricted instance: False

Un-restricted DnsPermission instance IsSubsetOf un-restricted instance: True

Restricted DnsPermission instance IsSubsetOf un-restricted instance: True

Restricted DnsPermission instance IsSubsetOf restricted 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