Inheritance: System.Security.CodeAccessPermission, IUnrestrictedPermission
Ejemplo n.º 1
0
		public void Unrestricted ()
		{
			ConfigurationPermission p = new ConfigurationPermission (PermissionState.Unrestricted);
			Assert.IsTrue (p.IsUnrestricted(), "A1");

			p = new ConfigurationPermission (PermissionState.None);
			Assert.IsFalse (p.IsUnrestricted(), "A2");
		}
Ejemplo n.º 2
0
		public void Intersect_null ()
		{
			ConfigurationPermission p1 = new ConfigurationPermission (PermissionState.Unrestricted);

			IPermission p3 = p1.Intersect (null);

			Assert.IsNull (p3, "A1");
		}
Ejemplo n.º 3
0
		public void Union ()
		{
			ConfigurationPermission p1 = new ConfigurationPermission (PermissionState.Unrestricted);
			ConfigurationPermission p2 = new ConfigurationPermission (PermissionState.None);

			IPermission p3 = p1.Union (p2);

			Assert.AreEqual (typeof (ConfigurationPermission), p3.GetType(), "A1");

			Assert.IsTrue (((ConfigurationPermission)p3).IsUnrestricted(), "A2");
		}
Ejemplo n.º 4
0
        public override IPermission Union(IPermission target)
        {
            if (target == null)
            {
                return(Copy());
            }

            ConfigurationPermission p = target as ConfigurationPermission;

            if (p == null)
            {
                throw new ArgumentException("target");
            }

            return(new ConfigurationPermission(unrestricted || p.IsUnrestricted() ? PermissionState.Unrestricted : PermissionState.None));
        }
Ejemplo n.º 5
0
        //
        // Compares two ConfigurationPermission instances
        //
        public override bool IsSubsetOf(IPermission target)
        {
            if (target == null)
            {
                return(_permissionState == PermissionState.None);
            }

            if (target.GetType() != typeof(ConfigurationPermission))
            {
                throw ExceptionUtil.ParameterInvalid("target");
            }

            ConfigurationPermission other = (ConfigurationPermission)target;

            return(_permissionState == PermissionState.None || other._permissionState == PermissionState.Unrestricted);
        }
Ejemplo n.º 6
0
        public override IPermission Intersect(IPermission target)
        {
            if (target == null)
            {
                return(null);
            }
            if (target.GetType() != typeof(ConfigurationPermission))
            {
                throw ExceptionUtil.ParameterInvalid("target");
            }
            if (this._permissionState == PermissionState.None)
            {
                return(new ConfigurationPermission(PermissionState.None));
            }
            ConfigurationPermission permission = (ConfigurationPermission)target;

            return(new ConfigurationPermission(permission._permissionState));
        }
Ejemplo n.º 7
0
        public override IPermission Union(IPermission target)
        {
            if (target == null)
            {
                return(this.Copy());
            }
            if (target.GetType() != typeof(ConfigurationPermission))
            {
                throw ExceptionUtil.ParameterInvalid("target");
            }
            if (this._permissionState == PermissionState.Unrestricted)
            {
                return(new ConfigurationPermission(PermissionState.Unrestricted));
            }
            ConfigurationPermission permission = (ConfigurationPermission)target;

            return(new ConfigurationPermission(permission._permissionState));
        }
Ejemplo n.º 8
0
        public override IPermission Intersect(IPermission target)
        {
            if (target == null)
            {
                return(null);
            }

            if (target.GetType() != typeof(ConfigurationPermission))
            {
                throw ExceptionUtil.ParameterInvalid("target");
            }

            // Create an None permission if either this or other is None
            if (_permissionState == PermissionState.None)
            {
                return(new ConfigurationPermission(PermissionState.None));
            }
            ConfigurationPermission other = (ConfigurationPermission)target;

            return(new ConfigurationPermission(other._permissionState));
        }
Ejemplo n.º 9
0
        public override IPermission Union(IPermission target)
        {
            if (target == null)
            {
                return(Copy());
            }

            if (target.GetType() != typeof(ConfigurationPermission))
            {
                throw ExceptionUtil.ParameterInvalid("target");
            }

            // Create an Unrestricted permission if either this or other is unrestricted
            if (_permissionState == PermissionState.Unrestricted)
            {
                return(new ConfigurationPermission(PermissionState.Unrestricted));
            }
            ConfigurationPermission other = (ConfigurationPermission)target;

            return(new ConfigurationPermission(other._permissionState));
        }
Ejemplo n.º 10
0
        public override bool IsSubsetOf(IPermission target)
        {
            if (target == null)
            {
                return(!unrestricted);
            }

            ConfigurationPermission p = target as ConfigurationPermission;

            if (p == null)
            {
                throw new ArgumentException("target");
            }

            if (unrestricted)
            {
                return(p.IsUnrestricted());
            }
            else
            {
                return(true);
            }
        }
Ejemplo n.º 11
0
		public void Intersect_wrongtype ()
		{
			ConfigurationPermission p1 = new ConfigurationPermission (PermissionState.Unrestricted);

			IPermission p3 = p1.Intersect (new StrongNameIdentityPermission (PermissionState.Unrestricted));
		}
Ejemplo n.º 12
0
		public void ToXml ()
		{
			ConfigurationPermission p = new ConfigurationPermission (PermissionState.Unrestricted);

#if NET_4_0
			Assert.AreEqual(
					"<IPermission class=\"System.Configuration.ConfigurationPermission, System.Configuration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a\"\nversion=\"1\"\nUnrestricted=\"true\"/>\n",
					p.ToString().Replace ("\r\n", "\n"), "A1");
#else
			Assert.AreEqual (
					"<IPermission class=\"System.Configuration.ConfigurationPermission, System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a\"\nversion=\"1\"\nUnrestricted=\"true\"/>\n",
					p.ToString ().Replace ("\r\n", "\n"), "A1");
#endif

			p = new ConfigurationPermission (PermissionState.None);

#if NET_4_0
			Assert.AreEqual (
					 "<IPermission class=\"System.Configuration.ConfigurationPermission, System.Configuration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a\"\nversion=\"1\"/>\n",
					 p.ToString().Replace ("\r\n", "\n"), "A2");
#else
			Assert.AreEqual (
					 "<IPermission class=\"System.Configuration.ConfigurationPermission, System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a\"\nversion=\"1\"/>\n",
					 p.ToString ().Replace ("\r\n", "\n"), "A2");
#endif
		}
Ejemplo n.º 13
0
		public void Subset_wrongtype ()
		{
			ConfigurationPermission p1 = new ConfigurationPermission (PermissionState.Unrestricted);

			Assert.IsFalse (p1.IsSubsetOf (new StrongNameIdentityPermission (PermissionState.Unrestricted)));
		}
Ejemplo n.º 14
0
		public void Subset ()
		{
			ConfigurationPermission p1 = new ConfigurationPermission (PermissionState.Unrestricted);
			ConfigurationPermission p2 = new ConfigurationPermission (PermissionState.None);

			Assert.IsFalse (p1.IsSubsetOf (p2), "A1");
			Assert.IsTrue  (p1.IsSubsetOf (p1), "A2");
			Assert.IsTrue  (p2.IsSubsetOf (p1), "A3");
			Assert.IsTrue  (p2.IsSubsetOf (p2), "A4");

			Assert.IsFalse (p1.IsSubsetOf (null), "A5");
			Assert.IsTrue (p2.IsSubsetOf (null), "A6");
		}
Ejemplo n.º 15
0
		public void Union_wrongtypee ()
		{
			ConfigurationPermission p1 = new ConfigurationPermission (PermissionState.Unrestricted);

			IPermission p3 = p1.Union (new StrongNameIdentityPermission (PermissionState.Unrestricted));
		}