public void FromXml_WrongTagCase()
        {
            UrlIdentityPermission uip = new UrlIdentityPermission(PermissionState.None);
            SecurityElement       se  = uip.ToXml();

            se.Tag = "IPERMISSION";             // instead of IPermission
            uip.FromXml(se);
        }
        public void FromXml_WrongTag()
        {
            UrlIdentityPermission uip = new UrlIdentityPermission(PermissionState.None);
            SecurityElement       se  = uip.ToXml();

            se.Tag = "IMono";
            uip.FromXml(se);
        }
        public void FromXml_WrongVersion()
        {
            UrlIdentityPermission uip = new UrlIdentityPermission(PermissionState.None);
            SecurityElement       se  = uip.ToXml();

            se.Attributes.Remove("version");
            se.Attributes.Add("version", "2");
            uip.FromXml(se);
        }
        public void FromXml_NoVersion()
        {
            UrlIdentityPermission uip = new UrlIdentityPermission(PermissionState.None);
            SecurityElement       se  = uip.ToXml();

            SecurityElement w = new SecurityElement(se.Tag);

            w.AddAttribute("class", se.Attribute("class"));
            uip.FromXml(w);
        }
        public void FromXml_NoClass()
        {
            UrlIdentityPermission uip = new UrlIdentityPermission(PermissionState.None);
            SecurityElement       se  = uip.ToXml();

            SecurityElement w = new SecurityElement(se.Tag);

            w.AddAttribute("version", se.Attribute("version"));
            uip.FromXml(w);
            // doesn't even care of the class attribute presence
        }
        public void FromXml_WrongClass()
        {
            UrlIdentityPermission uip = new UrlIdentityPermission(PermissionState.None);
            SecurityElement       se  = uip.ToXml();

            SecurityElement w = new SecurityElement(se.Tag);

            w.AddAttribute("class", "Wrong" + se.Attribute("class"));
            w.AddAttribute("version", se.Attribute("version"));
            uip.FromXml(w);
            // doesn't care of the class name at that stage
            // anyway the class has already be created so...
        }
Пример #7
0
        public static void UrlIdentityPermissionCallMethods()
        {
            UrlIdentityPermission uip  = new UrlIdentityPermission(new PermissionState());
            UrlIdentityPermission uip2 = new UrlIdentityPermission("testsite");
            IPermission           ip   = uip.Copy();
            IPermission           ip2  = uip.Intersect(ip);
            bool testbool = uip.IsSubsetOf(ip);

            ip2 = uip.Union(ip);
            SecurityElement se = new SecurityElement("");

            uip.FromXml(se);
            se = uip.ToXml();
        }
Пример #8
0
    //</Snippet5>
    //<Snippet6>
    // ToXml creates an XML encoding of the permission and its current state; FromXml reconstructs a
    // permission with the specified state from the XML encoding.
    private static void ToFromXmlDemo()
    {
        UrlIdentityPermission permIdPerm1 = new UrlIdentityPermission("http://www.fourthcoffee.com/process/*");
        UrlIdentityPermission permIdPerm2 = new UrlIdentityPermission(PermissionState.None);

        permIdPerm2.FromXml(permIdPerm1.ToXml());
        bool result = permIdPerm2.Equals(permIdPerm1);

        if (result)
        {
            Console.WriteLine("Result of ToFromXml = " + permIdPerm2.ToString());
        }
        else
        {
            Console.WriteLine(permIdPerm2.ToString());
            Console.WriteLine(permIdPerm1.ToString());
        }
    }
Пример #9
0
 public static void UrlIdentityPermissionCallMethods()
 {
     UrlIdentityPermission uip = new UrlIdentityPermission(new PermissionState());
     UrlIdentityPermission uip2 = new UrlIdentityPermission("testsite");
     IPermission ip = uip.Copy();
     IPermission ip2 = uip.Intersect(ip);
     bool testbool = uip.IsSubsetOf(ip);
     ip2 = uip.Union(ip);
     SecurityElement se = new SecurityElement("");
     uip.FromXml(se);
     se = uip.ToXml();
 }
Пример #10
0
        public void FromXml_Null()
        {
            UrlIdentityPermission uip = new UrlIdentityPermission(PermissionState.None);

            uip.FromXml(null);
        }