本文整理汇总了C#中IEnumerator.MoveNext方法的典型用法代码示例。如果您正苦于以下问题:C# IEnumerator.MoveNext方法的具体用法?C# IEnumerator.MoveNext怎么用?C# IEnumerator.MoveNext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IEnumerator
的用法示例。
在下文中一共展示了IEnumerator.MoveNext方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ProcessCurrentToken
private static IParsedValue ProcessCurrentToken(IEnumerator<IToken> iterator)
{
IToken tk = iterator.Current;
switch(tk.TokenType)
{
case TokenTypes.CHARCONST:
return new ParsedCharConst { Value = (tk as CharConstantToken).Value };
case TokenTypes.INTEGERCONST:
return new ParsedIntegerConst { Value = (tk as IntegerConstantToken).Value };
case TokenTypes.IDENTIFIER:
return new ParsedIdentifier { Name = (tk as IdentifierToken).Name };
case TokenTypes.STRINGCONST:
return new ParsedStringConst { Value = (tk as StringConstantToken).Value };
case TokenTypes.PARANTHESE:
if((tk as ParentheseToken).isOpening)
{
List<IParsedValue> content = new List<IParsedValue>();
iterator.MoveNext();
while(!((iterator.Current.TokenType == TokenTypes.PARANTHESE) && !((iterator.Current as ParentheseToken).isOpening)))
{
content.Add(ProcessCurrentToken(iterator));
iterator.MoveNext();
}
return new ParsedSExpr { Members = content };
}
else
throw new Exception("Parser: Shit just got real!/Unexpected parentesis.");
default:
return null;
}
}
示例2: ParseBackQuotedBasicForm
private CCObject ParseBackQuotedBasicForm(IEnumerator<CCObject> ts)
{
if (ts.Current == ParenL)
{
return new CCCons(new CCIdentifier() {Name="list"}, new CCCons(ParseBackQuotedList(ts), null));
}
else if (ts.Current == Comma)
{
if (!ts.MoveNext()) // to body
{
throw new CCParserException();
}
if (ts.Current == Atmark)
{
if (!ts.MoveNext()) // to body
{
throw new CCParserException();
}
return ts.Current;
}
else
{
return new CCCons(new CCIdentifier() {Name = "list"}, new CCCons(ts.Current, null));
}
}
else
{
return new CCCons(new CCIdentifier() { Name = "list" }, new CCCons(QuoteObject(ts.Current), null));
}
}
示例3: 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);
}
}
示例4: Main
static void Main(string[] args)
{
lines = File.ReadAllLines("Script.txt").GetEnumerator();
client = new TcpClient();
client.Connect(IPAddress.Loopback, 8091);
var stream = client.GetStream();
int i;
var readBuffer = new byte[256];
while ((i = stream.Read(readBuffer, 0, readBuffer.Length)) != 0)
{
lines.MoveNext();
var readSoFar = Encoding.ASCII.GetString(readBuffer, 0, i);
if (readSoFar == (string) lines.Current)
{
if (!lines.MoveNext()) break;
Thread.Sleep(1000);
var writeBuffer = Encoding.ASCII.GetBytes((string)lines.Current);
Console.WriteLine((string)lines.Current);
stream.Write(writeBuffer, 0, writeBuffer.Length);
}
}
Console.ReadLine();
}
示例5: GameState
public GameState(Game game_i)
{
game = game_i;
playerList = game.Players.GetEnumerator();
playerList.MoveNext();
currentPlayer = (Gpremacy.Player)playerList.Current;
//previousTerritory = null;
//arrowOn = false;
commandList = new ArrayList();
networkCommands = new Queue();
states = new ArrayList();
states.Add(new Orig_Play1Upkeep(game));
states.Add(new Orig_Play2Sell(game));
states.Add(new Orig_Play3Attack(game));
states.Add(new Orig_Play4Move(game));
states.Add(new Orig_Play5Build(game));
states.Add(new Orig_Play6Prospect(game));
stateList = states.GetEnumerator();
stateList.MoveNext();
currentState = (Gpremacy.State)stateList.Current;
stateList.MoveNext();
nextState = (Gpremacy.State)stateList.Current;
turnNumber = 1;
//nextPlayer();
//nextState();
GLib.Timeout.Add (1000, new GLib.TimeoutHandler (NetworkExecuteRun));
}
示例6: Parse
private static TempNode Parse(IEnumerator<Token> e)
{
if (e.Current.Type == TokenType.Identifier)
{
var node = new TempNode { Type = AstNodeType.Identifier, Value = e.Current.Value };
e.MoveNext();
node.AddNode(Parse(e));
return node;
}
if (e.Current.Type == TokenType.Dot)
{
var callNode = new TempNode { Type = AstNodeType.Call };
callNode.AddNode(ParseCallNode(e));
return callNode;
}
if (e.Current.Type == TokenType.String || e.Current.Type == TokenType.Number)
{
return new TempNode { Type = AstNodeType.Literal, Value = e.Current.Value };
}
if (e.MoveNext())
return Parse(e);
return null;
}
示例7: ParseAttribute
static Traversal ParseAttribute(IEnumerator<Token> enumerator)
{
if (enumerator.MoveNext())
{
var key = enumerator.Current;
if (enumerator.MoveNext())
{
var next = enumerator.Current;
if (next is AttributeEndToken)
{
return new HasAttribute(key.Value);
}
if (next is AttributeComparisonToken)
{
if (enumerator.MoveNext())
{
var next2 = enumerator.Current;
if (next2 is AttributeValueToken)
{
return new AttributeValueEquals(key.Value, next2.Value);
}
}
}
}
}
throw new ArgumentException("Invalid attribute expression");
}
示例8: GetMineFields
static List<MineField> GetMineFields(IEnumerator<string> lineEnumerator)
{
lineEnumerator.MoveNext();
MatchCollection metaData;
Regex firstLineIdentifier = new Regex(@"^(\d)? (\d)?$"), fieldLineIdentifier;
var grids = new List<MineField>();
while ((metaData = firstLineIdentifier.Matches(lineEnumerator.Current)).Count > 0)
{
int lines = Convert.ToInt32(metaData[0].Groups[1].Value),
columns = Convert.ToInt32(metaData[0].Groups[2].Value);
fieldLineIdentifier = new Regex(@"^(\" + MINE + @"|\" +SPACE + "){" + lines + "}");
var grid = new string[lines];
for (int i = 0; i < lines; i++)
{
lineEnumerator.MoveNext();
if (lineEnumerator.Current.Length > columns || !fieldLineIdentifier.IsMatch(lineEnumerator.Current)) // the regex already checks for the length but if there are more characters, we can catch that with a trivial greater than operation rather than with IsMatch of the Regex, which is more expensive
{
throw new Exception("So...either the number of symbols in the line exceed the total specified by the YOU before or the line contains invalid characters (Why would you do such a thing?). Be con·sist·ent");
}
grid[i] = lineEnumerator.Current;
}
grids.Add(new MineField(grid, MINE));
lineEnumerator.MoveNext();
}
return grids;
}
示例9: Run
public void Run (Test[] tests)
{
foreach (Test test in tests)
{
var methods = GetTestMethods (test);
foreach (System.Reflection.MethodInfo method in methods) {
this.testMethods.Add (new object[] { test, method });
}
}
this.testRun = testMethods.GetEnumerator ();
OnTestFinished += (t, method, time, exception) =>
{
if (testRun.MoveNext ()) {
RunTest (((Test)((object[])testRun.Current)[0]), ((System.Reflection.MethodInfo)((object[])testRun.Current)[1]));
} else {
if (OnTestsFinished != null)
{
OnTestsFinished();
}
}
};
if (testRun.MoveNext ()) {
RunTest ((Test)((object[])testRun.Current)[0], (System.Reflection.MethodInfo)((object[])testRun.Current)[1]);
}
}
示例10: 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;
}
}
示例11: AssertItemCountForEnumeratorIsEqualTo
protected static void AssertItemCountForEnumeratorIsEqualTo(int expectedCount, IEnumerator enumerator)
{
for (var i = 0; i < expectedCount; i++)
{
Assert.IsTrue(enumerator.MoveNext(), "Enumerator should contain a next item.");
}
Assert.IsFalse(enumerator.MoveNext(), "Enumerator should not contain a next item.");
}
示例12: ParseArguments
private static void ParseArguments(IEnumerator<Token> e, TempNode methodNode)
{
e.MoveNext();
while (e.Current.Type != TokenType.CloseParen)
{
methodNode.AddNode(Parse(e));
e.MoveNext();
}
}
示例13: RepositionIterator
/// <summary>
/// Reposition Forward Iterator to current location
/// </summary>
public void RepositionIterator(ref IEnumerator forwardIterator, object currentFrame )
{
forwardIterator.Reset();
forwardIterator.MoveNext();
while (forwardIterator.Current != currentFrame)
{
forwardIterator.MoveNext();
}
}
示例14: MoveOver
private void MoveOver(IEnumerator<string> linesIterator, Action<string> action, out bool linesIteratorEnded)
{
linesIteratorEnded = !linesIterator.MoveNext();
var line = linesIterator.Current;
while (!linesIteratorEnded && !line.StartsWith("[")) {
action(line);
linesIteratorEnded = !linesIterator.MoveNext();
line = linesIterator.Current;
}
}
示例15: TestStructualEqual
public static void TestStructualEqual(IEnumerator<TypeDescriber> expected, AstNode node)
{
if(!expected.MoveNext() || node == null) return;
var describer = expected.Current;
AssertType(describer.ExpectedType, node.Type);
foreach(var sibling in node.Siblings){
TestStructualEqual(expected.Current.Children.GetEnumerator(), node.FirstChild);
if(!expected.MoveNext())
Assert.Fail("Unexpected node found!");
}
}