当前位置: 首页>>代码示例>>C#>>正文


C# Evidence.AddAssembly方法代码示例

本文整理汇总了C#中System.Security.Policy.Evidence.AddAssembly方法的典型用法代码示例。如果您正苦于以下问题:C# Evidence.AddAssembly方法的具体用法?C# Evidence.AddAssembly怎么用?C# Evidence.AddAssembly使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Security.Policy.Evidence的用法示例。


在下文中一共展示了Evidence.AddAssembly方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Check

		public void Check ()
		{
			ApplicationDirectoryMembershipCondition ad = new ApplicationDirectoryMembershipCondition ();
			Evidence e = null;
			Assert.IsFalse (ad.Check (e), "Check (null)");
			e = new Evidence ();
			Assert.IsFalse (ad.Check (e), "Check (empty)");
			e.AddHost (new Zone (SecurityZone.MyComputer));
			Assert.IsFalse (ad.Check (e), "Check (zone)");

			string codebase = Assembly.GetExecutingAssembly ().CodeBase;
			Url u = new Url (codebase);
			ApplicationDirectory adir = new ApplicationDirectory (codebase);

			e.AddHost (u);
			Assert.IsFalse (ad.Check (e), "Check (url-host)"); // not enough
			e.AddAssembly (adir);
			Assert.IsFalse (ad.Check (e), "Check (url-host+adir-assembly)");

			e = new Evidence ();
			e.AddHost (adir);
			Assert.IsFalse (ad.Check (e), "Check (adir-host)"); // not enough
			e.AddAssembly (u);
			Assert.IsFalse (ad.Check (e), "Check (url-assembly+adir-host)");

			e = new Evidence ();
			e.AddHost (u);
			e.AddHost (adir);
			Assert.IsTrue (ad.Check (e), "Check (url+adir host)"); // both!!
		}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:30,代码来源:ApplicationDirectoryMembershipConditionTest.cs

示例2: Check

		public void Check ()
		{
			GacMembershipCondition gac = new GacMembershipCondition ();
			Evidence e = null;
			Assert.IsFalse (gac.Check (e), "Check (null)");
			e = new Evidence ();
			Assert.IsFalse (gac.Check (e), "Check (empty)");
			e.AddHost (new Zone (SecurityZone.MyComputer));
			Assert.IsFalse (gac.Check (e), "Check (zone)");
			GacInstalled g = new GacInstalled ();
			e.AddAssembly (g);
			Assert.IsFalse (gac.Check (e), "Check (gac-assembly)");
			e.AddHost (g);
			Assert.IsTrue (gac.Check (e), "Check (gac-host)");
		}
开发者ID:Profit0004,项目名称:mono,代码行数:15,代码来源:GacMembershipConditionTest.cs

示例3: Check

		public void Check ()
		{
			AllMembershipCondition all = new AllMembershipCondition ();
			Evidence e = null;
			Assert.IsTrue (all.Check (e), "Check (null)");
			e = new Evidence ();
			Assert.IsTrue (all.Check (e), "Check (empty)");
			e.AddHost (new Zone (SecurityZone.MyComputer));
			Assert.IsTrue (all.Check (e), "Check (zone)");
			Url u = new Url ("http://www.go-mono.com/");
			e.AddAssembly (u);
			Assert.IsTrue (all.Check (e), "Check (all-assembly)");
			Site s = new Site ("www.go-mono.com");
			e.AddHost (s);
			Assert.IsTrue (all.Check (e), "Check (all-host)");
		}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:16,代码来源:AllMembershipConditionTest.cs

示例4: AddAssembly

		public void AddAssembly ()
		{
			Evidence evidence = new Evidence ();
			object[] comparray = new object[100];
			string obj;

			for (int i=0; i<100; i++) {
				obj = String.Format ("asmb-{0}", i+1);
				comparray[i] = obj;
				evidence.AddAssembly (obj);
				Assert.AreEqual (evidence.Count, i+1);
			}
			
			int index = 0;
			foreach (object compobj in evidence) {
				Assert.AreEqual (comparray[index++], compobj, "Comparison object does not equal evidence assembly object");
			}
		}
开发者ID:narutopatel,项目名称:mono,代码行数:18,代码来源:EvidenceTest.cs

示例5: Check

		public void Check () 
		{
			SiteMembershipCondition smc = new SiteMembershipCondition ("*.go-mono.com");

			Evidence e = null;
			Assert.IsFalse (smc.Check (e), "Check(null)");
			e = new Evidence ();
			Assert.IsFalse (smc.Check (e), "Check (empty)");
			e.AddHost (new Zone (SecurityZone.MyComputer));
			Assert.IsFalse (smc.Check (e), "Check (zone)");
			
			Site s = new Site ("*.go-mono.com");
			e.AddAssembly (s);
			Assert.IsFalse (smc.Check (e), "Check (site-assembly)");
			e.AddHost (s);
			Assert.IsTrue (smc.Check (e), "Check (site-host)");

			e = new Evidence ();
			e.AddHost (new Site ("www.go-mono.com"));
			Assert.IsTrue (smc.Check (e), "Check(+-)");

			e = new Evidence ();
			e.AddHost (new Site ("*.go-mono.org"));
			Assert.IsFalse (smc.Check (e), "Check(-)");
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:25,代码来源:SiteMembershipConditionTest.cs

示例6: Clear

		public void Clear () 
		{
			Evidence e = new Evidence ();
			Assert.AreEqual (0, e.Count, "Count-Empty");
			e.AddAssembly (new object ());
			Assert.AreEqual (1, e.Count, "Count+Assembly");
			e.AddHost (new object ());
			Assert.AreEqual (2, e.Count, "Count+Host");
			e.Clear ();
			Assert.AreEqual (0, e.Count, "Count-Cleared");
		}
开发者ID:narutopatel,项目名称:mono,代码行数:11,代码来源:EvidenceTest.cs

示例7: RemoveType

		public void RemoveType ()
		{
			Evidence e = new Evidence ();
			Assert.AreEqual (0, e.Count, "Count-Empty");
			e.AddAssembly (new object ());
			e.AddHost (new object ());
			Assert.AreEqual (2, e.Count, "Count");
			e.RemoveType (typeof (object));
			Assert.AreEqual (0, e.Count, "Count-RemoveType(object)");
		}
开发者ID:narutopatel,项目名称:mono,代码行数:10,代码来源:EvidenceTest.cs

示例8: DecodeSerializedEvidence

        private static void DecodeSerializedEvidence( Evidence evidence,
                                               byte[] serializedEvidence )
        {
            BinaryFormatter formatter = new BinaryFormatter();
                
            Evidence asmEvidence = null;
                
            PermissionSet permSet = new PermissionSet( false );
            permSet.SetPermission( new SecurityPermission( SecurityPermissionFlag.SerializationFormatter ) );
            permSet.PermitOnly();
            permSet.Assert();

            try {
                using(MemoryStream ms = new MemoryStream( serializedEvidence ))
                    asmEvidence = (Evidence)formatter.Deserialize( ms );
            }
            catch
            {
            }
                
            if (asmEvidence != null)
            {
                IEnumerator enumerator = asmEvidence.GetAssemblyEnumerator();
                    
                while (enumerator.MoveNext())
                {
                    Object obj = enumerator.Current;
                    evidence.AddAssembly( obj );
                }
            }
        }       
开发者ID:gbarnett,项目名称:shared-source-cli-2.0,代码行数:31,代码来源:assembly.cs

示例9: Equals_GetHashCode

		public void Equals_GetHashCode () 
		{
			Evidence e1 = new Evidence ();
			Evidence e2 = new Evidence ();
			Assert.AreEqual (e1.GetHashCode (), e2.GetHashCode (), "GetHashCode-1");
			Assert.IsTrue (e1.Equals (e2), "e1.Equals(e2)");
			e1.AddAssembly (String.Empty);
			e2.AddAssembly (String.Empty);
			Assert.AreEqual (e1.GetHashCode (), e2.GetHashCode (), "GetHashCode-2");
			e1.AddHost (String.Empty);
			e2.AddHost (String.Empty);
			Assert.AreEqual (e1.GetHashCode (), e2.GetHashCode (), "GetHashCode-3");
			Assert.IsTrue (e2.Equals (e1), "e2.Equals(e1)");
		}
开发者ID:narutopatel,项目名称:mono,代码行数:14,代码来源:EvidenceTest.cs

示例10: DecodeSerializedEvidence

        private void DecodeSerializedEvidence( Evidence evidence,
                                               byte[] serializedEvidence )
        {
            MemoryStream ms = new MemoryStream( serializedEvidence );
            BinaryFormatter formatter = new BinaryFormatter();
                
            Evidence asmEvidence = null;
                
            PermissionSet permSet = new PermissionSet( false );
            permSet.SetPermission( new SecurityPermission( SecurityPermissionFlag.SerializationFormatter ) );
            permSet.PermitOnly();
            permSet.Assert();

            try
            {
                asmEvidence = (Evidence)formatter.Deserialize( ms );
            }
            catch (Exception)
            {
            }
                
            if (asmEvidence != null)
            {
                // Any evidence from the serialized input must:
                // 1. be placed in the assembly list since it is unverifiable.
                // 2. not be a built in class used as evidence (e.g. Zone, Site, URL, etc.)
                    
                IEnumerator enumerator = asmEvidence.GetAssemblyEnumerator();
                    
                while (enumerator.MoveNext())
                {
                    Object obj = enumerator.Current;

                    if (!(obj is Zone || obj is Site || obj is Url || obj is StrongName || obj is PermissionRequestEvidence))
                        evidence.AddAssembly( obj );
                }
            }
        }       
开发者ID:ArildF,项目名称:masters,代码行数:38,代码来源:assembly.cs

示例11: GetDefaultDomainIdentity

		private static Evidence GetDefaultDomainIdentity()
		{
			Evidence evidence = new Evidence();
			bool zoneEvidence = false;
			IEnumerator hostEnumerator = AppDomain.CurrentDomain.Evidence.GetHostEnumerator();
			while (hostEnumerator.MoveNext())
			{
				if (hostEnumerator.Current is Zone)
					zoneEvidence = true;
				evidence.AddHost(hostEnumerator.Current);
			}
			hostEnumerator = AppDomain.CurrentDomain.Evidence.GetAssemblyEnumerator();
			while (hostEnumerator.MoveNext())
			{
				evidence.AddAssembly(hostEnumerator.Current);
			}
			if (!zoneEvidence)
				evidence.AddHost(new Zone(SecurityZone.MyComputer));
			return evidence;
		}
开发者ID:DarkActive,项目名称:daFluorineFx,代码行数:20,代码来源:ApplicationManager.cs

示例12: Check

		public void Check ()
		{
			HashMembershipCondition hash = new HashMembershipCondition (md5, digestMd5);
			Evidence e = null;
			Assert.IsFalse (hash.Check (e), "Check (null)");
			e = new Evidence ();
			Assert.IsFalse (hash.Check (e), "Check (empty)");
			e.AddHost (new Zone (SecurityZone.MyComputer));
			Assert.IsFalse (hash.Check (e), "Check (zone)");
			e.AddAssembly (hashEvidence);
			Assert.IsFalse (hash.Check (e), "Check (hash-assembly)");

			e = new Evidence ();
			e.AddHost (hashEvidence);
			Assert.IsTrue (hash.Check (e), "Check (MD5-host)");

			hash = new HashMembershipCondition (sha1, digestSha1);
			Assert.IsTrue (hash.Check (e), "Check (SHA1-host)");
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:19,代码来源:HashMembershipConditionTest.cs

示例13: ResolveEvidenceAssembly

		private void ResolveEvidenceAssembly (SecurityZone zone)
		{
			string prefix = zone.ToString () + "-";
			Evidence e = new Evidence ();
			e.AddAssembly (new Zone (zone));
			PermissionSet ps = SecurityManager.ResolvePolicy (e);
			Assert.AreEqual (0, ps.Count, prefix + "Count");
			Assert.IsTrue (ps.IsEmpty (), prefix + "IsEmpty");
			Assert.IsFalse (ps.IsUnrestricted (), prefix + "IsUnrestricted");
		}
开发者ID:nlhepler,项目名称:mono,代码行数:10,代码来源:SecurityManagerTest.cs

示例14: Check

		public void Check () 
		{
			UrlMembershipCondition umc = new UrlMembershipCondition ("http://www.go-mono.com");

			Evidence e = null;
			Assert.IsFalse (umc.Check (e), "Check(null)");

			e = new Evidence ();
			Assert.IsFalse (umc.Check (e), "Check(empty)");

			e.AddHost (new Zone (SecurityZone.MyComputer));
			Assert.IsFalse (umc.Check (e), "Check(zone)");

			Url u = new Url ("http://www.go-mono.com");
			e.AddAssembly (u);
			Assert.IsFalse (umc.Check (e), "Check(url-assembly)");
			e.AddHost (u);
			Assert.IsTrue (umc.Check (e), "Check(url-host)");
		}
开发者ID:Profit0004,项目名称:mono,代码行数:19,代码来源:UrlMembershipConditionTest.cs

示例15: MakeResourceAssemblyEvidence

        internal static void MakeResourceAssemblyEvidence( Evidence input, out Evidence output, out StrongName outputSn )
        {
            IEnumerator eviEnumerator = input.GetHostEnumerator();

            output = new Evidence();
            outputSn = null;

            while (eviEnumerator.MoveNext())
            {
                if (eviEnumerator.Current is StrongName)
                {
                    StrongName inputSn = (StrongName)eviEnumerator.Current;

                    outputSn = new StrongName( inputSn.PublicKey, inputSn.Name + ".resource", inputSn.Version );

                    output.AddHost( outputSn );
                }
                else
                {
                    output.AddHost( eviEnumerator.Current );
                }
            }

            eviEnumerator = input.GetAssemblyEnumerator();

            while (eviEnumerator.MoveNext())
            {
                output.AddAssembly( eviEnumerator.Current );
            }
        }
开发者ID:gbarnett,项目名称:shared-source-cli-2.0,代码行数:30,代码来源:caspol.cs


注:本文中的System.Security.Policy.Evidence.AddAssembly方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。