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


C# Location.AddLine方法代码示例

本文整理汇总了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);
		}
开发者ID:stuartcarnie,项目名称:Mono.TextTemplating,代码行数:27,代码来源:Tokeniser.cs

示例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;
		}
开发者ID:stuartcarnie,项目名称:Mono.TextTemplating,代码行数:43,代码来源:Tokeniser.cs

示例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);
		}
开发者ID:stuartcarnie,项目名称:Mono.TextTemplating,代码行数:34,代码来源:Tokeniser.cs

示例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);;
		}
开发者ID:stuartcarnie,项目名称:Mono.TextTemplating,代码行数:30,代码来源:Tokeniser.cs


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