本文整理汇总了C#中Token.As方法的典型用法代码示例。如果您正苦于以下问题:C# Token.As方法的具体用法?C# Token.As怎么用?C# Token.As使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Token
的用法示例。
在下文中一共展示了Token.As方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TokenFactoryImpl
private static DocumentToken TokenFactoryImpl(Token token, List<DocumentToken> previous)
{
var utToken = token.As<DocumentToken>();
DocumentTokenType? previousNonWhitespaceTokenType = null;
for(var i = previous.Count-1;i >= 0; i--)
{
var current = previous[i];
if(string.IsNullOrWhiteSpace(current.Value) == false)
{
previousNonWhitespaceTokenType = current.TokenType;
break;
}
}
DocumentTokenType constantValueType;
if(TryParseDocumentTokenType(token.Value, out constantValueType))
{
utToken.TokenType = constantValueType;
}
else if (previousNonWhitespaceTokenType.HasValue && (previousNonWhitespaceTokenType.Value == DocumentTokenType.BeginReplacementSegment || previousNonWhitespaceTokenType.Value == DocumentTokenType.BeginTerminateReplacementSegment))
{
utToken.TokenType = DocumentTokenType.ReplacementKey;
}
else if (previousNonWhitespaceTokenType.HasValue && (previousNonWhitespaceTokenType.Value == DocumentTokenType.ReplacementKey || previousNonWhitespaceTokenType.Value == DocumentTokenType.ReplacementParameter))
{
utToken.TokenType = DocumentTokenType.ReplacementParameter;
}
else
{
utToken.TokenType = DocumentTokenType.PlainText;
}
return utToken;
}
示例2: TokenFactoryImpl
/// <summary>
/// A method that can determine which type of token the given value is
/// </summary>
/// <param name="token">The token to classify</param>
/// <param name="previous">Previously classified tokens in the source string</param>
/// <returns>The classified token</returns>
public static ObjectPathToken TokenFactoryImpl(Token token, List<ObjectPathToken> previous)
{
var ret = token.As<ObjectPathToken>();
if (ret.Value == "[")
{
ret.TokenType = ObjectPathTokenType.IndexerOpen;
}
else if (ret.Value == "]")
{
ret.TokenType = ObjectPathTokenType.IndexerClose;
}
else if (ret.Value == ".")
{
ret.TokenType = ObjectPathTokenType.NavigationElement;
}
else if (ret.Value.StartsWith("\"") && ret.Value.EndsWith("\"") && ret.Value.Length > 1)
{
ret.TokenType = ObjectPathTokenType.StringLiteral;
}
else if(string.IsNullOrWhiteSpace(ret.Value))
{
ret.TokenType = ObjectPathTokenType.Whitespace;
}
else
{
ret.TokenType = ObjectPathTokenType.Identifier;
}
return ret;
}