Union() 공개 메소드

public Union ( IPermission target ) : IPermission
target IPermission
리턴 IPermission
		private StrongNameIdentityPermission GetUnion ()
		{
			StrongNamePublicKeyBlob blob = new StrongNamePublicKeyBlob (ecma);
			StrongNameIdentityPermission snip = new StrongNameIdentityPermission (blob, "mono", new Version (1, 2, 3, 4));
			StrongNamePublicKeyBlob blob2 = new StrongNamePublicKeyBlob (new byte[16]);
			StrongNameIdentityPermission diffPk = new StrongNameIdentityPermission (blob2, "mono", new Version (1, 2, 3, 4));
			return (StrongNameIdentityPermission)snip.Union (diffPk);
		}
		public void Union_DifferentPermissions ()
		{
			StrongNameIdentityPermission a = new StrongNameIdentityPermission (PermissionState.None);
			SecurityPermission b = new SecurityPermission (PermissionState.None);
			a.Union (b);
		}
		public void Union_SamePublicKey_DifferentVersion ()
		{
			StrongNamePublicKeyBlob blob = new StrongNamePublicKeyBlob (ecma);
			StrongNameIdentityPermission snip = new StrongNameIdentityPermission (blob, "mono", new Version (1, 2, 3, 4));
			StrongNameIdentityPermission diffVersion = new StrongNameIdentityPermission (blob, null, new Version (1, 2));
			StrongNameIdentityPermission result = (StrongNameIdentityPermission) snip.Union (diffVersion);
#if NET_2_0
			Assert.IsNotNull (result, "DifferentVersion");
			// new XML format is used to contain more than one site
			SecurityElement se = result.ToXml ();
			Assert.AreEqual (2, se.Children.Count, "Childs");
			Assert.AreEqual ("1.2.3.4", (se.Children [0] as SecurityElement).Attribute ("AssemblyVersion"), "AssemblyVersion#1");
			Assert.AreEqual ("1.2", (se.Children [1] as SecurityElement).Attribute ("AssemblyVersion"), "AssemblyVersion#2");
			// strangely it is still versioned as 'version="1"'.
			Assert.AreEqual ("1", se.Attribute ("version"), "Version");
#else
			Assert.IsNull (result, "DifferentVersion");
#endif
		}
		public void Union ()
		{
			StrongNamePublicKeyBlob blob = new StrongNamePublicKeyBlob (ecma);
			StrongNameIdentityPermission snip = new StrongNameIdentityPermission (blob, "mono", new Version (1, 2, 3, 4));

			StrongNameIdentityPermission union = (StrongNameIdentityPermission)snip.Union (null);
			Compare (snip, union, "snip U null");

			StrongNameIdentityPermission empty = new StrongNameIdentityPermission (PermissionState.None);
			union = (StrongNameIdentityPermission)snip.Union (empty);
			Compare (snip, union, "snip U empty");

			union = (StrongNameIdentityPermission)snip.Union (snip);
			Compare (snip, union, "snip U snip");

			// note: can't be tested with PermissionState.Unrestricted

			StrongNameIdentityPermission samePk = new StrongNameIdentityPermission (blob, null, null);
			union = (StrongNameIdentityPermission)snip.Union (samePk);
#if !NET_2_0
			// can't compare the properties with multiple entries
			Compare (snip, union, "snip U samePk");
#endif
			Assert.IsTrue (snip.IsSubsetOf (union), "snip.IsSubsetOf (union)");

			union = (StrongNameIdentityPermission)samePk.Union (snip);
#if !NET_2_0
			// can't compare the properties with multiple entries
			Compare (snip, union, "samePk U snip");
#endif
			Assert.IsTrue (samePk.IsSubsetOf (union), "snip.IsSubsetOf (union)");
		}
		public void Union_SamePublicKey_DifferentName ()
		{
			StrongNamePublicKeyBlob blob = new StrongNamePublicKeyBlob (ecma);
			StrongNameIdentityPermission snip = new StrongNameIdentityPermission (blob, "mono", new Version (1, 2, 3, 4));
			StrongNameIdentityPermission diffName = new StrongNameIdentityPermission (blob, "novell", null);
			StrongNameIdentityPermission result = (StrongNameIdentityPermission) snip.Union (diffName);
			Assert.IsNotNull (result, "DifferentName");
			// new XML format is used to contain more than one site
			SecurityElement se = result.ToXml ();
			Assert.AreEqual (2, se.Children.Count, "Childs");
			Assert.AreEqual ("mono", (se.Children [0] as SecurityElement).Attribute ("Name"), "Name#1");
			Assert.AreEqual ("novell", (se.Children [1] as SecurityElement).Attribute ("Name"), "Name#2");
			// strangely it is still versioned as 'version="1"'.
			Assert.AreEqual ("1", se.Attribute ("version"), "Version");
		}