Пример #1
0
        public void FromXml_NameEmpty()
        {
            StrongNameIdentityPermission snip = new StrongNameIdentityPermission(PermissionState.None);
            SecurityElement se = snip.ToXml();

            snip.FromXml(se);

            snip.PublicKey = new StrongNamePublicKeyBlob(ecma);
            snip.Version   = new Version("1.2.3.4");
            se             = snip.ToXml();
            snip.FromXml(se);
        }
Пример #2
0
        public void FromXml_WrongTagCase()
        {
            StrongNameIdentityPermission snip = new StrongNameIdentityPermission(PermissionState.None);
            SecurityElement se = snip.ToXml();

            se.Tag = "IPERMISSION";             // instead of IPermission
            snip.FromXml(se);
        }
Пример #3
0
        public void FromXml_WrongTag()
        {
            StrongNameIdentityPermission snip = new StrongNameIdentityPermission(PermissionState.None);
            SecurityElement se = snip.ToXml();

            se.Tag = "IMono";
            snip.FromXml(se);
        }
Пример #4
0
        public void FromXml_WrongVersion()
        {
            StrongNameIdentityPermission snip = new StrongNameIdentityPermission(PermissionState.None);
            SecurityElement se = snip.ToXml();

            se.Attributes.Remove("version");
            se.Attributes.Add("version", "2");
            snip.FromXml(se);
        }
Пример #5
0
        public void FromXml_NoVersion()
        {
            StrongNameIdentityPermission snip = new StrongNameIdentityPermission(PermissionState.None);
            SecurityElement se = snip.ToXml();

            SecurityElement w = new SecurityElement(se.Tag);

            w.AddAttribute("class", se.Attribute("class"));
            snip.FromXml(w);
        }
Пример #6
0
        public void FromXml_NoClass()
        {
            StrongNameIdentityPermission snip = new StrongNameIdentityPermission(PermissionState.None);
            SecurityElement se = snip.ToXml();

            SecurityElement w = new SecurityElement(se.Tag);

            w.AddAttribute("version", se.Attribute("version"));
            snip.FromXml(w);
            // doesn't even care of the class attribute presence
        }
Пример #7
0
        public void FromXml_WrongClass()
        {
            StrongNameIdentityPermission snip = new StrongNameIdentityPermission(PermissionState.None);
            SecurityElement se = snip.ToXml();

            SecurityElement w = new SecurityElement(se.Tag);

            w.AddAttribute("class", "Wrong" + se.Attribute("class"));
            w.AddAttribute("version", se.Attribute("version"));
            snip.FromXml(w);
            // doesn't care of the class name at that stage
            // anyway the class has already be created so...
        }
Пример #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 bool ToFromXmlDemo()
    {
        bool returnValue = true;

        StrongNameIdentityPermission snIdPerm1, snIdPerm2;

        snIdPerm1 = new StrongNameIdentityPermission(blob, "MyCompany.MyDepartment.*", new Version("1.0.0.0"));
        snIdPerm2 = new StrongNameIdentityPermission(PermissionState.None);
        snIdPerm2.FromXml(snIdPerm1.ToXml());
        Console.WriteLine("Result of ToFromXml = " + snIdPerm2.ToString() + "\n");

        return(returnValue);
    }
Пример #9
0
        public static void StrongNameIdentityPermissionCallMethods()
        {
            StrongNameIdentityPermission snip  = new StrongNameIdentityPermission(new Permissions.PermissionState());
            StrongNameIdentityPermission snip2 = new StrongNameIdentityPermission(new Permissions.StrongNamePublicKeyBlob(new byte[1]), "test", new Version(1, 2));
            IPermission ip       = snip.Copy();
            IPermission ip2      = snip.Intersect(ip);
            bool        testbool = snip.IsSubsetOf(ip);

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

            snip.FromXml(se);
            se = snip.ToXml();
        }
Пример #10
0
 public static void StrongNameIdentityPermissionCallMethods()
 {
     StrongNameIdentityPermission snip = new StrongNameIdentityPermission(new Permissions.PermissionState());
     StrongNameIdentityPermission snip2 = new StrongNameIdentityPermission(new Permissions.StrongNamePublicKeyBlob(new byte[1]), "test", new System.Version(1, 2));
     IPermission ip = snip.Copy();
     IPermission ip2 = snip.Intersect(ip);
     bool testbool = snip.IsSubsetOf(ip);
     ip2 = snip.Union(ip);
     SecurityElement se = new SecurityElement("");
     snip.FromXml(se);
     se = snip.ToXml();
 }
Пример #11
0
        public void FromXml_Null()
        {
            StrongNameIdentityPermission snip = new StrongNameIdentityPermission(PermissionState.None);

            snip.FromXml(null);
        }
Пример #12
0
	// 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 bool ToFromXmlDemo()
	{

		bool returnValue = true;

		StrongNameIdentityPermission snIdPerm1, snIdPerm2;

		snIdPerm1 = new StrongNameIdentityPermission(blob, "MyCompany.MyDepartment.*", new Version("1.0.0.0"));
		snIdPerm2 = new StrongNameIdentityPermission(PermissionState.None);
		snIdPerm2.FromXml(snIdPerm1.ToXml());
		Console.WriteLine("Result of ToFromXml = " + snIdPerm2.ToString() + "\n");

		return returnValue;

	}