本文整理汇总了C#中ITokenSource类的典型用法代码示例。如果您正苦于以下问题:C# ITokenSource类的具体用法?C# ITokenSource怎么用?C# ITokenSource使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ITokenSource类属于命名空间,在下文中一共展示了ITokenSource类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ProcessTerm
public bool ProcessTerm(ITokenSource source)
{
var term = new ArraySegmentKey<char>(source.Buffer, source.Size);
if (_stopWords.Contains(term))
return false;
return true;
}
示例2: ExecuteQueryFunc
public List<Result> ExecuteQueryFunc(Query query, ITokenSource cancelToken)
{
if (QueryFunc != null) {
return QueryFunc(query, cancelToken);
}
return new List<Result>();
}
示例3: ProcessTerm
public bool ProcessTerm(ITokenSource source)
{
for (int i = 0; i < source.Size; i++)
{
source.Buffer[i] = char.ToLowerInvariant(source.Buffer[i]);
}
return true;
}
示例4: Process
public bool Process(string field, ITokenSource source)
{
for (int i = 0; i < _filters.Length; i++)
{
if (_filters[i].ProcessTerm(source) == false)
return false;
}
return true;
}
示例5: Run
// public object Run(string parameters)//, CancellationToken ct)
// {
// for (int i = 0; i < 2; i++)
// {
// //ct.ThrowIfCancellationRequested();
// Thread.Sleep(5000);
// }
// return "Hello from MyCustomJob in App1";
// }
public void Run(ITokenSource tokenSource)
{
for (int i = 0; i < 5; i++)
{
tokenSource.Token.ThrowIfCancellationRequested();
Thread.Sleep(5000);
}
AutoMapper.Mapper.CreateMap<Class1, Class2>();
}
示例6: ProcessTerm
public bool ProcessTerm(ITokenSource source)
{
if (source.Size <= 2)
return true;
if (source.Buffer[source.Size - 1] == '\'') // remove "boys' ball" suffix '
{
source.Size--;
}
// remove "boy's ball" suffix 's
else if ((source.Buffer[source.Size - 1] == 's') && source.Buffer[source.Size - 2] == '\'')
{
source.Size -= 2;
}
return true;
}
示例7: Parse
/// <summary>
/// Parses the given token source using the specified grammar, starting with
/// expression with the given name.
/// </summary>
/// <param name="expressionType">The type of the expression to start parsing.</param>
/// <param name="tokenSource">The source of tokens.</param>
public MatchResult Parse(string expressionType, ITokenSource tokenSource)
{
if (tokenSource == null)
{
throw new ArgumentNullException("tokenSource");
}
Expression expression = grammar.Expression(expressionType);
ParseAttempt attempt = new ParseAttempt(this, tokenSource);
MatchResult result = expression.Match(attempt, String.Empty);
// check that there are no trailing tokens
if (result.IsMatch && attempt.GetToken() != null)
{
result.IsMatch = false;
}
return result;
}
示例8: CommonTokenStream
public CommonTokenStream(ITokenSource tokenSource, int channel)
: base(tokenSource)
{
this._channel = channel;
}
示例9: ConstructToken
protected internal virtual IToken ConstructToken(ITokenSource tokenSource, int expectedTokenType, string tokenText, IToken current)
{
ITokenFactory factory = tokenSource.TokenFactory;
return factory.Create(Tuple.Create(tokenSource, current.TokenSource.InputStream), expectedTokenType, tokenText, TokenConstants.DefaultChannel, -1, -1, current.Line, current.Column);
}
示例10: UnbufferedTokenStream
public UnbufferedTokenStream(ITokenSource tokenSource, int bufferSize)
{
this.TokenSource = tokenSource;
this.tokens = new IToken[bufferSize];
n = 0;
Fill(1);
}
示例11: TokenRewriteStream
public TokenRewriteStream(ITokenSource tokenSource, int channel)
: base(tokenSource, channel)
{
Init();
}
示例12: NadirTokenStream
public NadirTokenStream(ITokenSource tokenSource, int channel) : base(tokenSource, channel)
{
}
示例13: CommonTokenStream
/// <summary>
/// Constructs a new
/// <see cref="CommonTokenStream"/>
/// using the specified token
/// source and the default token channel (
/// <see cref="TokenConstants.DefaultChannel"/>
/// ).
/// </summary>
/// <param name="tokenSource">The token source.</param>
public CommonTokenStream(ITokenSource tokenSource)
: base(tokenSource)
{
}
示例14: TokenStreamRemovable
public TokenStreamRemovable(ITokenSource tokenSource, int channel) : base(tokenSource, channel) { }
示例15: LegacyCommonTokenStream
public LegacyCommonTokenStream(ITokenSource tokenSource)
: this()
{
this._tokenSource = tokenSource;
}