Intersect() публичный Метод

public Intersect ( IPermission target ) : IPermission
target IPermission
Результат IPermission
Пример #1
0
		public void IntersectWithBadPermission () 
		{
			ReflectionPermission p1 = new ReflectionPermission (ReflectionPermissionFlag.NoFlags);
			EnvironmentPermission ep2 = new EnvironmentPermission (PermissionState.Unrestricted);
			ReflectionPermission p3 = (ReflectionPermission) p1.Intersect (ep2);
		}
Пример #2
0
		public void IntersectWithUnrestricted () 
		{
			ReflectionPermission p1 = new ReflectionPermission (PermissionState.Unrestricted);
			ReflectionPermission p2 = new ReflectionPermission (ReflectionPermissionFlag.MemberAccess);
			ReflectionPermission p3 = (ReflectionPermission) p1.Intersect (p2);
			Assert.IsTrue (!p3.IsUnrestricted (), "Unrestricted N P2 == P2");
			Assert.AreEqual (p2.ToXml ().ToString (), p3.ToXml ().ToString (), "Unrestricted N EP2 == EP2");
			p3 = (ReflectionPermission) p2.Intersect (p1);
			Assert.IsTrue (!p3.IsUnrestricted (), "P2 N Unrestricted == P2");
			Assert.AreEqual (p2.ToXml ().ToString (), p3.ToXml ().ToString (), "P2 N Unrestricted == P2");

			p2 = new ReflectionPermission (ReflectionPermissionFlag.NoFlags);
			p3 = (ReflectionPermission) p1.Intersect (p2);
			Assert.IsNull (p3, "Unrestricted N None == null");
		}
Пример #3
0
		public void Intersect () 
		{
			// no intersection
			ReflectionPermission p1 = new ReflectionPermission (ReflectionPermissionFlag.MemberAccess);
			ReflectionPermission p2 = new ReflectionPermission (ReflectionPermissionFlag.TypeInformation);
			ReflectionPermission p3 = (ReflectionPermission) p1.Intersect (p2);
			Assert.IsNull (p3, "EP1 N EP2 == null");
			// intersection in MemberAccess
			ReflectionPermission p4 = new ReflectionPermission (ReflectionPermissionFlag.MemberAccess | ReflectionPermissionFlag.ReflectionEmit);
			p3 = (ReflectionPermission) p4.Intersect (p1);
			Assert.AreEqual (ReflectionPermissionFlag.MemberAccess, p3.Flags, "Intersect-MemberAccess");
			// intersection in TypeInformation
			ReflectionPermission p5 = new ReflectionPermission (ReflectionPermissionFlag.TypeInformation | ReflectionPermissionFlag.ReflectionEmit);
			p3 = (ReflectionPermission) p5.Intersect (p2);
			Assert.AreEqual (ReflectionPermissionFlag.TypeInformation, p3.Flags, "Intersect-TypeInformation");
			// intersection in AllFlags
			ReflectionPermission p6 = new ReflectionPermission (ReflectionPermissionFlag.AllFlags);
			ReflectionPermission p7 = new ReflectionPermission (ReflectionPermissionFlag.AllFlags);
			p3 = (ReflectionPermission) p6.Intersect (p7);
			Assert.AreEqual (ReflectionPermissionFlag.AllFlags, p3.Flags, "Intersect-AllFlags");
			Assert.IsTrue (p3.IsUnrestricted (), "Intersect-AllFlags-Unrestricted");
		}
Пример #4
0
		public void IntersectWithNull () 
		{
			ReflectionPermission p1 = new ReflectionPermission (ReflectionPermissionFlag.NoFlags);
			ReflectionPermission p2 = null;
			ReflectionPermission p3 = (ReflectionPermission) p1.Intersect (p2);
			Assert.IsNull (p3, "P1 N null == null");
		}