本文整理汇总了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;
}
示例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);
}
示例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;
}
}
示例4: EnumeratorDecorator
IEnumerator EnumeratorDecorator(IEnumerator enumerator, TaskRoutine task)
{
while (enumerator.MoveNext() == true)
yield return enumerator.Current;
_pool.Enqueue(task);
}
示例5: PartiallyClosedCircuitBreakerState
public PartiallyClosedCircuitBreakerState(CircuitBreaker breaker, Exception exception,
IEnumerator<int> timeoutEnumerator)
: base(breaker)
{
_exception = exception;
_timeoutEnumerator = timeoutEnumerator;
}
示例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;
}
示例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;
}
示例8: EnumeratorSeq
public EnumeratorSeq(IEnumerator enumerator)
{
_enumerator = enumerator;
_state = new State();
_state._val = _state;
_state._rest = _state;
}
示例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;
}
示例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();
}
示例11: AddAll
public virtual void AddAll(IEnumerator iterator)
{
while (iterator.MoveNext())
{
Add(iterator.Current);
}
}
示例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;
}
示例13: Awake
void Awake()
{
watcherCoroutine = extendedFingerWatcher();
if(HandModel == null){
HandModel = gameObject.GetComponentInParent<IHandModel>();
}
}
示例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();
}
}
}
}
示例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;
}