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


C# Evidence.GetEnumerator方法代码示例

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


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

示例1: DefaultConstructor

		public void DefaultConstructor ()
		{
			Evidence evidence = new Evidence ();
			
			AssertEquals ("Default constructor count should be zero", evidence.Count, 0);
			AssertEquals ("Default constructor host enumerator MoveNext() should be false", 
				evidence.GetHostEnumerator().MoveNext(), false);
			AssertEquals ("Default constructor assembly enumerator MoveNext() should be false",
				evidence.GetAssemblyEnumerator().MoveNext(), false);
			AssertEquals ("Default constructor enumerator MoveNext() should be false",
				evidence.GetEnumerator().MoveNext(), false);
		}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:12,代码来源:EvidenceTest.cs

示例2: MakeEvidenceArray

        internal static char[] MakeEvidenceArray( Evidence evidence, bool verbose )
        {
			// We only support caching on our built-in evidence types (excluding hash b/c it would
			// make our caching scheme just match up the same assembly from the same location which
			// doesn't gain us anything).

            IEnumerator enumerator = evidence.GetEnumerator();
            int requiredLength = 0;

            while (enumerator.MoveNext())
            {
                IBuiltInEvidence obj = enumerator.Current as IBuiltInEvidence;

                if (obj == null)
                    return null;

                requiredLength += obj.GetRequiredSize(verbose);
            }

            enumerator.Reset();

            char[] buffer = new char[requiredLength];

            int position = 0;

            while (enumerator.MoveNext())
            {   
                position = ((IBuiltInEvidence)enumerator.Current).OutputToBuffer( buffer, position, verbose );
            }

            return buffer;
        }
开发者ID:ArildF,项目名称:masters,代码行数:32,代码来源:policymanager.cs

示例3: Resolve

        public PermissionSet Resolve(Evidence evidence, PermissionSet request)
        {
#if _DEBUG    
            if (debug)
            {
                DEBUG_OUT("PolicyManager::Resolve");
                IEnumerator evidenceEnumerator = evidence.GetEnumerator();
                DEBUG_OUT("Evidence:");
                while (evidenceEnumerator.MoveNext())
                {
                    Object obj = evidenceEnumerator.Current;
                    if (obj is Site)
                    {
                        DEBUG_OUT( ((Site)obj).ToXml().ToString() );
                    }
                    else if (obj is Zone)
                    {
                        DEBUG_OUT( ((Zone)obj).ToXml().ToString() );
                    }
                    else if (obj is Url)
                    {
                        DEBUG_OUT( ((Url)obj).ToXml().ToString() );
                    }
                    else if (obj is StrongName)
                    {
                        DEBUG_OUT( ((StrongName)obj).ToXml().ToString() );
                    }
                    else if (obj is PermissionRequestEvidence)
                    {
                        DEBUG_OUT( ((PermissionRequestEvidence)obj).ToXml().ToString() );
                    }
                }
            }
#endif

            // We set grant to null to represent "AllPossible"

            PermissionSet grant = null;
            PolicyStatement policy;
            PolicyLevel currentLevel = null;

            IEnumerator levelEnumerator = m_levels.GetEnumerator();
            
            char[] serializedEvidence = MakeEvidenceArray( evidence, false );
            int count = evidence.Count;

            bool testApplicationLevels = false;
            
            while (levelEnumerator.MoveNext())
            {
                currentLevel = (PolicyLevel)levelEnumerator.Current;
                policy = currentLevel.Resolve( evidence, count, serializedEvidence );

                // If the grant is "AllPossible", the intersection is just the other permission set.
                // Otherwise, do an inplace intersection (since we know we can alter the grant set since
                // it is a copy of the first policy statement's permission set).
                
                if (grant == null)
                {
                    grant = policy.PermissionSet;
                }
                else
                {
                    // An exception somewhere in here means that a permission
                    // failed some operation.  This simply means that it will be
                    // dropped from the grant set which is safe operation that
                    // can be ignored.
                
                    try
                    {
                        grant.InplaceIntersect( policy.GetPermissionSetNoCopy() );
                    }
                    catch (Exception)
                    {
                    }
                }
                    
    #if _DEBUG        
                if (debug)
                {
                    DEBUG_OUT( "Level = " + currentLevel.Label );
                    DEBUG_OUT( "policy =\n" + policy.ToXml().ToString() );
                    DEBUG_OUT( "grant so far =\n" + grant.ToXml().ToString() );
                }
    #endif

                if (grant.IsEmpty())
                {
                    break;
                }
                else if ((policy.Attributes & PolicyStatementAttribute.LevelFinal) == PolicyStatementAttribute.LevelFinal)
                {
                    if (!currentLevel.Label.Equals( "AppDomain" ))
                    {
                        testApplicationLevels = true;
                    }

                    break;
                }
            }
//.........这里部分代码省略.........
开发者ID:ArildF,项目名称:masters,代码行数:101,代码来源:policymanager.cs

示例4: EnumeratorReset

		public void EnumeratorReset ()
		{
			object[] hostarray = { "host-1", "host-2", "host-3", "host-4" };
			object[] asmbarray = { "asmb-1", "asmb-2", "asmb-3", "asmb-4" };
			ArrayList compare = new ArrayList (); 
			Evidence evidence = new Evidence (hostarray, asmbarray);
			compare.AddRange (hostarray);
			compare.AddRange (asmbarray);

			int i = 0;
			IEnumerator enumerator = evidence.GetEnumerator ();	
			while (enumerator.MoveNext ()) {
				Assert.AreEqual (enumerator.Current, compare[i++]);
			}

			enumerator.Reset ();
			i = 0;
			while (enumerator.MoveNext ()) {
				Assert.AreEqual (enumerator.Current, compare[i++]);
			}
		}
开发者ID:narutopatel,项目名称:mono,代码行数:21,代码来源:EvidenceTest.cs


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