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


C# IEnumerator类代码示例

本文整理汇总了C#中IEnumerator的典型用法代码示例。如果您正苦于以下问题:C# IEnumerator类的具体用法?C# IEnumerator怎么用?C# IEnumerator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: IterIsolateEnumerator

            internal IterIsolateEnumerator(IEnumerator enumerator)
            {
                // if this is the enumerator from another iterator, we
                    // don't have to enumerate it; we'll just steal the arraylist
                    // to use for ourselves.
                IterIsolateEnumerator chainedEnumerator =
                    enumerator as IterIsolateEnumerator;

                if (chainedEnumerator != null)
                {
                    items = chainedEnumerator.items;
                }
                else
                {
                    items = new ArrayList();
                    while (enumerator.MoveNext() != false)
                    {
                        items.Add(enumerator.Current);
                    }
                    IDisposable disposable = enumerator as IDisposable;
                    if (disposable != null)
                    {
                        disposable.Dispose();
                    }
                }
                currentItem = -1;
            }
开发者ID:Quarterback16,项目名称:GerardGui,代码行数:27,代码来源:IterIsolate.cs

示例2: OnTriggerStay2D

    /*private bool firstTime=false;

    void OnTriggerStay2D(Collider2D theOther)
    { 
        player = theOther.transform.gameObject;
       
        if (pressingDown()&&!firstTime)
        {
            StartCoroutine(preparingRitual());
        }
    }
    void PlayDestroySound()
    {
        gameObject.GetComponent<AudioSource>().Play();

    }

    private bool pressingDown()
    {
        return Input.GetKey(KeyCode.S) || Input.GetKey(KeyCode.DownArrow);
    }

    private IEnumerator preparingRitual()
    {
        firstTime = true;
        float startTime, actualTime, duration, time;
        bool ritualStarted = false;
        time = 1f;
        startTime = Time.time;
        while (pressingDown())
        {
            actualTime = Time.time;
            duration = actualTime - startTime;
            if (duration >= 2f && !ritualStarted)
            {
                startRitual();
                ritualStarted = true;
            }
            yield return new WaitForSeconds(time);
        }
        yield return null;
    }

    private void startRitual()
    {
        this.transform.gameObject.SetActive(false);
        player.GetComponent<StressUpdater>().decreaseAnxiety(0.5f);
        firstTime = false;
    }*/

    void OnTriggerEnter2D(Collider2D theOther)
    {
        player = theOther.transform.gameObject;
        player.gameObject.GetComponent<PlatformerCharacter2D>().triggerRitual();
        removeAnxietyCoroutine = removeAnxiety();
        StartCoroutine(removeAnxietyCoroutine);
    }
开发者ID:koop4,项目名称:GlobalGameJam,代码行数:57,代码来源:RitualObjectTrigger.cs

示例3: ParseRoute

        private static StringBuilder ParseRoute(IEnumerator<char> tokenizer, StringBuilder routePattern, IDictionary<string, string> routeParametersVsNamedGroup, IList<string> queryParameters)
        {
            char nextCharacterInRoute = tokenizer.Current;

            if (nextCharacterInRoute == '{')
            {
                tokenizer.MoveNext();
                return ParseRouteParameter(tokenizer, routePattern, routeParametersVsNamedGroup, queryParameters);
            }
            else if (nextCharacterInRoute == '?')
            {
                routePattern.Append(Regex.Escape(nextCharacterInRoute.ToString(CultureInfo.InvariantCulture)));
                tokenizer.MoveNext();
                return ParseQueryStringParameters(tokenizer, routePattern, queryParameters);
            }
            else
            {
                routePattern.Append(Regex.Escape(nextCharacterInRoute.ToString(CultureInfo.InvariantCulture)));
                if (tokenizer.MoveNext())
                    return ParseRoute(tokenizer, routePattern, routeParametersVsNamedGroup, queryParameters);
                else
                    return routePattern;

            }
        }
开发者ID:ToshB,项目名称:nservicestub,代码行数:25,代码来源:QueryStringParser.cs

示例4: EnumeratorDecorator

        IEnumerator EnumeratorDecorator(IEnumerator enumerator, TaskRoutine task)
        {
            while (enumerator.MoveNext() == true)
                yield return enumerator.Current;

            _pool.Enqueue(task);
        }
开发者ID:minhhh,项目名称:TaskRunner,代码行数:7,代码来源:TaskRoutinePool.cs

示例5: PartiallyClosedCircuitBreakerState

 public PartiallyClosedCircuitBreakerState(CircuitBreaker breaker, Exception exception,
     IEnumerator<int> timeoutEnumerator)
     : base(breaker)
 {
     _exception = exception;
     _timeoutEnumerator = timeoutEnumerator;
 }
开发者ID:TheOrangeBook,项目名称:FeatherVane,代码行数:7,代码来源:PartiallyClosedCircuitBreakerState.cs

示例6: Create

        private Sequence<InstructionNode> Create(IEnumerator<XamlInstruction> stream)
        {
            var nodes = new Sequence<InstructionNode>();

            while (IsLeading(stream.Current))
            {
                var currentNode = new InstructionNode { Leading = stream.Current };
                var continueWorking = true;
                while (stream.MoveNext() && continueWorking)
                {
                    if (IsLeading(stream.Current))
                    {
                        currentNode.Children = Create(stream);
                    }

                    var xamlNode = stream.Current;

                    if (IsTrailing(xamlNode))
                    {
                        continueWorking = false;
                        currentNode.Trailing = stream.Current;
                    }
                    else
                    {
                        currentNode.Body.Add(stream.Current);
                    }
                }

                nodes.Add(currentNode);
            }

            return nodes;
        }
开发者ID:grokys,项目名称:OmniXAML,代码行数:33,代码来源:InstructionTreeBuilder.cs

示例7: MemoryRepository

 /// <summary>
 /// Parametrized constructor
 /// </summary>
 /// <param name="enumerator">enumerator that generates id for users(Fibonacci enumerator by default)</param>
 /// <param name="path">file path</param>
 public MemoryRepository(IEnumerator<int> enumerator, string path)
 {
     if (enumerator != null)
         _enumerator = enumerator;
     if (path != null)
         _xmlPath = path;
 }
开发者ID:RomanMakarov1002,项目名称:EPAM.RD.2016S.Makarau,代码行数:12,代码来源:MemoryRepository.cs

示例8: EnumeratorSeq

 public EnumeratorSeq(IEnumerator enumerator)
 {
     _enumerator = enumerator;
     _state = new State();
     _state._val = _state;
     _state._rest = _state;
 }
开发者ID:TerabyteX,项目名称:clojure-clr,代码行数:7,代码来源:EnumeratorSeq.cs

示例9: GetTestCases

        public override IEnumerable GetTestCases()
        {
            ArrayList testCases = new ArrayList();
#endif
            IEnumerator[] enumerators = new IEnumerator[Sources.Length];
            int index = -1;

            for (; ; )
            {
                while (++index < Sources.Length)
                {
                    enumerators[index] = Sources[index].GetEnumerator();
                    if (!enumerators[index].MoveNext())
						return testCases;
                }

                object[] testdata = new object[Sources.Length];

                for (int i = 0; i < Sources.Length; i++)
                    testdata[i] = enumerators[i].Current;

                ParameterSet parms = new ParameterSet();
                parms.Arguments = testdata;
				testCases.Add(parms);

                index = Sources.Length;

                while (--index >= 0 && !enumerators[index].MoveNext()) ;

                if (index < 0) break;
            }

			return testCases;
        }
开发者ID:ChadBurggraf,项目名称:NUnitLite,代码行数:34,代码来源:CombinatorialStrategy.cs

示例10: Task

 /// Creates a new Task object for the given coroutine.
 ///
 /// If autoStart is true (default) the task is automatically started
 /// upon construction.
 public Task(IEnumerator c, bool autoStart = true)
 {
     task = TaskManager.CreateTask(c);
     task.Finished += TaskFinished;
     if (autoStart)
         Start();
 }
开发者ID:SMBNoog,项目名称:IsleOfAdventure,代码行数:11,代码来源:TaskManager.cs

示例11: AddAll

		public virtual void AddAll(IEnumerator iterator)
		{
			while (iterator.MoveNext())
			{
				Add(iterator.Current);
			}
		}
开发者ID:erdincay,项目名称:db4o,代码行数:7,代码来源:SortedCollection4.cs

示例12: DecodeByteArray

        private static byte[] DecodeByteArray(IEnumerator<byte> enumerator)
        {
            List<byte> lengthBytes = new List<byte>();

            // scan until we get to divider
            do
            {
                if( enumerator.Current == ByteArrayDivider )
                    break;

                lengthBytes.Add(enumerator.Current);
            }
            while (enumerator.MoveNext());

            string lengthString = System.Text.Encoding.UTF8.GetString(lengthBytes.ToArray());

            int length;
            if (!Int32.TryParse(lengthString, out length))
                throw new Exception("unable to parse length of byte array");

            // now read in the actual byte array
            byte[] bytes = new byte[length];

            for (int i = 0; i < length; i++)
            {
                enumerator.MoveNext();
                bytes[i] = enumerator.Current;
            }

            return bytes;
        }
开发者ID:RyanKirkpatrick,项目名称:research-bittorrent,代码行数:31,代码来源:BEncoding.cs

示例13: Awake

 void Awake()
 {
     watcherCoroutine = extendedFingerWatcher();
       if(HandModel == null){
     HandModel = gameObject.GetComponentInParent<IHandModel>();
       }
 }
开发者ID:xire-,项目名称:graphulus,代码行数:7,代码来源:ExtendedFingerDetector.cs

示例14: Next

 public virtual void Next()
 {
     if (enumerator == null)
     {
         enumerator = Steps.GetEnumerator();
         enumerator.MoveNext();
         step = enumerator.Current;
         this.OnNext(Step);
     }
     else
     {
         if (Step != Steps.Last())
         {
             enumerator.MoveNext();
             step = enumerator.Current;
             this.OnNext(Step);
         }
         else
         {
             if (OnFinished != null)
             {
                 OnFinished();
             }
         }
     }
 }
开发者ID:TylerKendrick,项目名称:Wizadry.NET,代码行数:26,代码来源:Wizard.cs

示例15: VertexEdgesEnumerator

 /// <summary>
 /// Construct an enumerator over the out-edges
 /// </summary>
 /// <param name="vertexOutEdges">Out edge dictionary to iterate</param>
 /// <exception cref="ArgumentNullException">vertexOutEdges is null</exception>
 public VertexEdgesEnumerator(VertexEdgesDictionary vertexOutEdges)
 {
     if (vertexOutEdges == null)
         throw new ArgumentNullException("vertexOutEdges");
     VertexOutEdgeEnumerator = vertexOutEdges.GetEnumerator();
     OutEdgeEnumerator = null;
 }
开发者ID:BackupTheBerlios,项目名称:mbunit-svn,代码行数:12,代码来源:VertexEdgesEnumerator.cs


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