本文整理汇总了C#中Location.AddLine方法的典型用法代码示例。如果您正苦于以下问题:C# Location.AddLine方法的具体用法?C# Location.AddLine怎么用?C# Location.AddLine使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Location
的用法示例。
在下文中一共展示了Location.AddLine方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetBlockEnd
State GetBlockEnd ()
{
int start = position;
for (; position < content.Length; position++) {
char c = content[position];
nextStateTagStartLocation = nextStateLocation;
nextStateLocation = nextStateLocation.AddCol ();
if (c == '\r') {
if (position + 1 < content.Length && content[position + 1] == '\n')
position++;
nextStateLocation = nextStateLocation.AddLine();
} else if (c == '\n') {
nextStateLocation = nextStateLocation.AddLine();
} else if (c =='>' && content[position-1] == '#' && content[position-2] != '\\') {
value = content.Substring (start, position - start - 1);
position++;
TagEndLocation = nextStateLocation;
//skip newlines directly after blocks, unless they're expressions
if (State != State.Expression && (position += IsNewLine()) > 0) {
nextStateLocation = nextStateLocation.AddLine ();
}
return State.Content;
}
}
throw new ParserException ("Unexpected end of file.", nextStateLocation);
}
示例2: NextStateInContent
State NextStateInContent ()
{
int start = position;
for (; position < content.Length; position++) {
char c = content[position];
nextStateTagStartLocation = nextStateLocation;
nextStateLocation = nextStateLocation.AddCol ();
if (c == '\r') {
if (position + 1 < content.Length && content[position + 1] == '\n')
position++;
nextStateLocation = nextStateLocation.AddLine();
} else if (c == '\n') {
nextStateLocation = nextStateLocation.AddLine();
} else if (c =='<' && position + 2 < content.Length && content[position+1] == '#') {
TagEndLocation = nextStateLocation;
char type = content[position+2];
if (type == '@') {
nextStateLocation = nextStateLocation.AddCols (2);
value = content.Substring (start, position - start);
position += 3;
return State.Directive;
} else if (type == '=') {
nextStateLocation = nextStateLocation.AddCols (2);
value = content.Substring (start, position - start);
position += 3;
return State.Expression;
} else if (type == '+') {
nextStateLocation = nextStateLocation.AddCols (2);
value = content.Substring (start, position - start);
position += 3;
return State.Helper;
} else {
value = content.Substring (start, position - start);
nextStateLocation = nextStateLocation.AddCol ();
position += 2;
return State.Block;
}
}
}
//EOF is only valid when we're in content
value = content.Substring (start);
return State.EOF;
}
示例3: NextStateInDirective
State NextStateInDirective () {
for (; position < content.Length; position++) {
char c = content[position];
if (c == '\r') {
if (position + 1 < content.Length && content[position + 1] == '\n')
position++;
nextStateLocation = nextStateLocation.AddLine();
} else if (c == '\n') {
nextStateLocation = nextStateLocation.AddLine();
} else if (Char.IsLetter (c)) {
return State.DirectiveName;
} else if (c == '=') {
nextStateLocation = nextStateLocation.AddCol ();
position++;
return State.DirectiveValue;
} else if (c == '#' && position + 1 < content.Length && content[position+1] == '>') {
position+=2;
TagEndLocation = nextStateLocation.AddCols (2);
nextStateLocation = nextStateLocation.AddCols (3);
//skip newlines directly after directives
if ((position += IsNewLine()) > 0) {
nextStateLocation = nextStateLocation.AddLine();
}
return State.Content;
} else if (!Char.IsWhiteSpace (c)) {
throw new ParserException ("Directive ended unexpectedly with character '" + c + "'", nextStateLocation);
} else {
nextStateLocation = nextStateLocation.AddCol ();
}
}
throw new ParserException ("Unexpected end of file.", nextStateLocation);
}
示例4: GetDirectiveValue
State GetDirectiveValue ()
{
int start = position;
int delimiter = '\0';
for (; position < content.Length; position++) {
char c = content[position];
nextStateLocation = nextStateLocation.AddCol ();
if (c == '\r') {
if (position + 1 < content.Length && content[position + 1] == '\n')
position++;
nextStateLocation = nextStateLocation.AddLine();
} else if (c == '\n')
nextStateLocation = nextStateLocation.AddLine();
if (delimiter == '\0') {
if (c == '\'' || c == '"') {
start = position;
delimiter = c;
} else if (!Char.IsWhiteSpace (c)) {
throw new ParserException ("Unexpected character '" + c + "'. Expecting attribute value.", nextStateLocation);
}
continue;
}
if (c == delimiter) {
value = content.Substring (start + 1, position - start - 1);
position++;
return State.Directive;
}
}
throw new ParserException ("Unexpected end of file.", nextStateLocation);;
}