本文整理汇总了C#中IEnumerator类的典型用法代码示例。如果您正苦于以下问题:C# IEnumerator类的具体用法?C# IEnumerator怎么用?C# IEnumerator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IEnumerator类属于命名空间,在下文中一共展示了IEnumerator类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: StartCoroutineAsync
/// <summary>
/// Start a co-routine on a background thread.
/// </summary>
/// <param name="task">Gets a task object with more control on the background thread.</param>
/// <returns></returns>
public static Coroutine StartCoroutineAsync(
this MonoBehaviour behaviour, IEnumerator routine,
out Task task)
{
task = new Task(routine);
return behaviour.StartCoroutine(task);
}
开发者ID:einargizz,项目名称:pgworld,代码行数:12,代码来源:ThreadNinjaMonoBehaviourExtensions.cs
示例14: Match
internal Match(ParseStep parseStep, IEnumerator<ParseStep> stepEnumerator, IEnumerable<IList<ParenCapture>> captureSet)
: base(0, parseStep.InitialStateIndex, parseStep.MatchedText.Length, parseStep.MatchedText, true)
{
_stepEnumerator = stepEnumerator;
Groups = new GroupCollection();
Groups.Append(this);
Captures.Prepend(this);
foreach (var parenCaptures in captureSet)
{
var parenCapture = parenCaptures[0];
var group = new Group(parenCapture.Number,
parenCapture.Index,
parenCapture.Value.Length,
parenCapture.Value,
parenCapture.Success);
Groups.Append(group);
if (parenCapture.Success)
{
group.Captures.Prepend(group);
}
if (parenCaptures.Skip(1).All(c => c.Success))
{
for (int i = 1; i < parenCaptures.Count; i++)
{
group.Captures.Prepend(new Capture(parenCaptures[i].Index,
parenCaptures[i].Value.Length,
parenCaptures[i].Value));
}
}
}
}
开发者ID:HeatherTooill,项目名称:RegExpose,代码行数:35,代码来源:Match.cs
示例15: ParseQueryStringParameters
private static StringBuilder ParseQueryStringParameters(IEnumerator<char> tokenizer, StringBuilder routePattern, IList<string> queryParameters)
{
var parameterName = new StringBuilder();
bool endOfStream = false;
while (!endOfStream && tokenizer.Current != '&')
{
parameterName.Append(tokenizer.Current);
endOfStream = !tokenizer.MoveNext();
}
string param = parameterName.ToString();
routePattern.Append(string.Format(@"(?<{0}{2}>[^=\?&]+)=(?<{1}{2}>[^&]+)", QueryParameterGroupName, QueryParameterValueGroupName, queryParameters.Count));
queryParameters.Add(param);
if (endOfStream)
return routePattern;
else
{
routePattern.Append(Regex.Escape(tokenizer.Current.ToString(CultureInfo.InvariantCulture)));
tokenizer.MoveNext();
return ParseQueryStringParameters(tokenizer, routePattern, queryParameters);
}
}
开发者ID:ToshB,项目名称:nservicestub,代码行数:25,代码来源:QueryStringParser.cs
示例16: CollectIndexedNodes
private void CollectIndexedNodes(IEnumerator qcons)
{
while (qcons.MoveNext())
{
QCon qcon = (QCon)qcons.Current;
if (IsCached(qcon))
{
continue;
}
if (IsLeaf(qcon))
{
if (qcon.CanLoadByIndex() && qcon.CanBeIndexLeaf())
{
QConObject conObject = (QConObject)qcon;
if (conObject.HasJoins())
{
CollectJoinedNode(conObject);
}
else
{
CollectStandaloneNode(conObject);
}
}
}
else
{
if (!qcon.HasJoins())
{
CollectIndexedNodes(qcon.IterateChildren());
}
}
}
}
开发者ID:superyfwy,项目名称:db4o,代码行数:33,代码来源:IndexedNodeCollector.cs
示例17: Awake
void Awake()
{
watcherCoroutine = extendedFingerWatcher();
if(HandModel == null){
HandModel = gameObject.GetComponentInParent<IHandModel>();
}
}
开发者ID:xire-,项目名称:graphulus,代码行数:7,代码来源:ExtendedFingerDetector.cs
示例18: 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
示例19: 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
示例20: ShowLetter
public void ShowLetter(int num)
{
if(currentCourutine != null)
{
StopCoroutine(currentCourutine);
currentCourutine = null;
}
full.SetActive(true);
letters[num].SetActive(true);
letters[num].transform.localScale = new Vector3(4f, 4f, 4f);
iTween.ScaleTo(letters[num].gameObject,
iTween.Hash(
"scale", new Vector3(1, 1, 1),
"time", 0.45f,
/* "onstart", (System.Action<object>)(newVal => logo1.color = new Color(logo1.color.r, logo1.color.g, logo1.color.b, 1)),*/
"easetype", iTween.EaseType.easeInCubic,
"oncomplete", "ShakeCamera",
"oncompletetarget", gameObject
)
);
currentCourutine = HideFull();
StartCoroutine(currentCourutine);
}
开发者ID:taboo1,项目名称:arena,代码行数:26,代码来源:WordRideCanvas.cs
注:本文中的IEnumerator类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论