Esempio n. 1
0
        public void Union_DifferentPermissions()
        {
            UIPermission       a = new UIPermission(PermissionState.None);
            SecurityPermission b = new SecurityPermission(PermissionState.None);

            a.Union(b);
        }
Esempio n. 2
0
    // </Snippet2>
    // <Snippet3>
    // Union creates a new permission that is the union of the current permission
    // and the specified permission.
    private static void UnionDemo()
    {
        UIPermission uiPerm1 = new UIPermission(UIPermissionWindow.SafeTopLevelWindows);
        UIPermission uiPerm2 = new UIPermission(UIPermissionWindow.SafeSubWindows);
        UIPermission p3      = (UIPermission)uiPerm1.Union(uiPerm2);

        try
        {
            if (p3 != null)
            {
                Console.WriteLine("The union of " + uiPerm1.Window.ToString() +
                                  " and \n\t" + uiPerm2.Window.ToString() + " is \n\t"
                                  + p3.Window.ToString() + "\n");
            }
            else
            {
                Console.WriteLine("The union of " + uiPerm1.Window.ToString() +
                                  " and \n\t" + uiPerm2.Window.ToString() + " is null.\n");
            }
        }
        catch (SystemException e)
        {
            Console.WriteLine("The union of " + uiPerm1.Window.ToString() +
                              " and \n\t" + uiPerm2.Window.ToString() + " failed.");

            Console.WriteLine(e.Message);
        }
    }
Esempio n. 3
0
        public void Union()
        {
            UIPermission none  = new UIPermission(PermissionState.None);
            UIPermission union = (UIPermission)none.Union(null);

            Compare(none, union, "none U null");
            Assert.IsFalse(Object.ReferenceEquals(none, union), "!ReferenceEquals1");
            Assert.IsTrue(none.IsSubsetOf(union), "none.IsSubsetOf (union)");

            union = (UIPermission)none.Union(new UIPermission(PermissionState.None));
            Assert.IsNull(union, "none U none");
            Assert.IsTrue(none.IsSubsetOf(null), "none.IsSubsetOf (null)");

            UIPermission unrestricted = new UIPermission(PermissionState.Unrestricted);

            union = (UIPermission)none.Union(unrestricted);
            Compare(unrestricted, union, "none U unrestricted");
            Assert.IsTrue(union.IsUnrestricted(), "IsUnrestricted-1");
            Assert.IsFalse(Object.ReferenceEquals(unrestricted, union), "!ReferenceEquals2");
            Assert.IsTrue(none.IsSubsetOf(union), "none.IsSubsetOf (union)");
            Assert.IsTrue(unrestricted.IsSubsetOf(union), "unrestricted.IsSubsetOf (union)");

            union = (UIPermission)unrestricted.Union(unrestricted);
            Compare(unrestricted, union, "unrestricted U unrestricted");
            Assert.IsTrue(union.IsUnrestricted(), "IsUnrestricted-2");
            Assert.IsFalse(Object.ReferenceEquals(unrestricted, union), "!ReferenceEquals3");
            Assert.IsTrue(unrestricted.IsSubsetOf(union), "unrestricted.IsSubsetOf (union)");

            UIPermission clip_all = new UIPermission(UIPermissionClipboard.AllClipboard);
            UIPermission win_all  = new UIPermission(UIPermissionWindow.AllWindows);

            union = (UIPermission)clip_all.Union(win_all);
            Compare(unrestricted, union, "clip_all U win_all");
            Assert.IsTrue(union.IsUnrestricted(), "IsUnrestricted-3");
            Assert.IsTrue(clip_all.IsSubsetOf(union), "clip_all.IsSubsetOf (union)");
            Assert.IsTrue(win_all.IsSubsetOf(union), "win_all.IsSubsetOf (union)");
        }
Esempio n. 4
0
        public static void UIPermissionCallMethods()
        {
            UIPermission uip      = new UIPermission(new PermissionState());
            UIPermission uip2     = new UIPermission(new UIPermissionClipboard());
            UIPermission uip3     = new UIPermission(new UIPermissionWindow());
            UIPermission uip4     = new UIPermission(new UIPermissionWindow(), new UIPermissionClipboard());
            IPermission  ip       = uip.Copy();
            IPermission  ip2      = uip.Intersect(ip);
            bool         testbool = uip.IsSubsetOf(ip);

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

            uip.FromXml(se);
            se = uip.ToXml();
        }
Esempio n. 5
0
    // </Snippet2>
    // <Snippet3>
    // Union creates a new permission that is the union of the current permission
    // and the specified permission.
    private static void UnionDemo()
    {
        UIPermission uiPerm1 = new UIPermission(UIPermissionWindow.SafeTopLevelWindows);
        UIPermission uiPerm2 = new UIPermission(UIPermissionWindow.SafeSubWindows);
        UIPermission p3      = (UIPermission)uiPerm1.Union(uiPerm2);

        if (p3 != null)
        {
            Console.WriteLine("The union of " + uiPerm1.Window.ToString() +
                              " and \n\t" + uiPerm2.Window.ToString() + " is \n\t"
                              + p3.Window.ToString() + "\n");
        }
        else
        {
            Console.WriteLine("The union of " + uiPerm1.Window.ToString() +
                              " and \n\t" + uiPerm2.Window.ToString() + " is null.\n");
        }
    }
Esempio n. 6
0
 public static void UIPermissionCallMethods()
 {
     UIPermission uip = new UIPermission(new PermissionState());
     UIPermission uip2 = new UIPermission(new UIPermissionClipboard());
     UIPermission uip3 = new UIPermission(new UIPermissionWindow());
     UIPermission uip4 = new UIPermission(new UIPermissionWindow(), new UIPermissionClipboard());
     IPermission ip = uip.Copy();
     IPermission ip2 = uip.Intersect(ip);
     bool testbool = uip.IsSubsetOf(ip);
     testbool = uip.IsUnrestricted();
     ip2 = uip.Union(ip);
     SecurityElement se = new SecurityElement("");
     uip.FromXml(se);
     se = uip.ToXml();
 }