本文整理汇总了C#中IToken类的典型用法代码示例。如果您正苦于以下问题:C# IToken类的具体用法?C# IToken怎么用?C# IToken使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IToken类属于命名空间,在下文中一共展示了IToken类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetFunctionDefinitionEndToken
IToken GetFunctionDefinitionEndToken()
{
if (functionDefinitionEndToken == null) {
functionDefinitionEndToken = ast.GetToken(methodDefinition.TokenStopIndex);
}
return functionDefinitionEndToken;
}
示例2: ASTNode
public ASTNode(IToken token)
{
_startIndex = -1;
_stopIndex = -1;
_childIndex = -1;
_token = token;
}
示例3: EmitAssign
public void EmitAssign(IToken token, object value)
{
EmitPop(token);
//function.Add(AsmTemplate.Assign(token.Text, value));
// MapFunction(token);
}
示例4: DefineTemplateAlias
public override CompiledTemplate DefineTemplateAlias(IToken aliasT, IToken targetT)
{
CompiledTemplate result = base.DefineTemplateAlias(aliasT, targetT);
_templateInformation.Add(new TemplateInformation(aliasT, targetT, result));
return result;
}
示例5: CreateConsumerRequest
public IConsumerRequest CreateConsumerRequest(IOAuthContext context, IOAuthConsumerContext consumerContext, IToken token)
{
if (context == null) throw new ArgumentNullException("context");
if (consumerContext == null) throw new ArgumentNullException("consumerContext");
return new ConsumerRequest(context, consumerContext, token);
}
示例6: Delete
public void Delete(IToken token)
{
if (_tokens.ContainsKey(token.UserId))
{
_tokens.Remove(token.UserId);
}
}
示例7: Syntax
protected override ParsedSyntax Syntax(ParsedSyntax left, IToken token, ParsedSyntax right)
{
if(left == null || right == null)
return base.Syntax(left, token, right);
return left.Equal(token, right);
}
示例8: GetComments
public static string[] GetComments(IToken[] FileTokens, List<IToken> alreadyTakenComments, int lastTokenLineNo,
int prevTokenIndex, int nextTokenIndex, bool acn = false)
{
List<string> comments = new List<string>();
int WS = acn ? acnLexer.WS : asn1Lexer.WS;
int COMMENT = acn ? acnLexer.COMMENT : asn1Lexer.COMMENT;
int COMMENT2 = acn ? acnLexer.COMMENT2 : asn1Lexer.COMMENT2;
//first see if there comments on the same line
while (nextTokenIndex >= 0 && nextTokenIndex < FileTokens.Length)
{
IToken t = FileTokens[nextTokenIndex++];
if (alreadyTakenComments.Contains(t))
{
break;
}
if (t.Line != lastTokenLineNo)
{
break;
}
if (t.Type == WS)
{
continue;
}
else if (t.Type == COMMENT || t.Type == COMMENT2)
{
comments.Insert(0, t.Text);
alreadyTakenComments.Add(t);
}
else
{
break;
}
}
//if no comments were found at the same line, then look back (above)
if (comments.Count == 0)
{
while (prevTokenIndex >= 0 && prevTokenIndex < FileTokens.Length)
{
IToken t = FileTokens[prevTokenIndex--];
if (alreadyTakenComments.Contains(t))
break;
if (t.Type == WS)
continue;
else if (t.Type == COMMENT || t.Type == COMMENT2)
{
comments.Insert(0, t.Text);
alreadyTakenComments.Add(t);
}
else
break;
}
}
return comments.ToArray();
}
示例9: SetAccessToken
// helper extension method to sign each JSON request with OAuth
public static void SetAccessToken(this JsonServiceClient client, IToken access_token)
{
// we use a request filter to add the required OAuth header
client.LocalHttpWebRequestFilter += webservice_request => {
OAuthConsumerContext consumer_context = new OAuthConsumerContext ();
consumer_context.SignatureMethod = "HMAC-SHA1";
consumer_context.ConsumerKey = access_token.ConsumerKey;
consumer_context.ConsumerSecret = "anyone";
consumer_context.UseHeaderForOAuthParameters = true;
// the OAuth process creates a signature, which uses several data from
// the web request like method, hostname, headers etc.
OAuthContext request_context = new OAuthContext ();
request_context.Headers = webservice_request.Headers;
request_context.RequestMethod = webservice_request.Method;
request_context.RawUri = webservice_request.RequestUri;
// now create the signature for that context
consumer_context.SignContextWithToken (request_context, access_token);
// BUG TODO the oauth_token is not included when generating the header,
// this is a bug ing DevDefined.OAuth. We add it manually as a workaround
request_context.AuthorizationHeaderParameters.Add ("oauth_token", access_token.Token);
string oauth_header = request_context.GenerateOAuthParametersForHeader ();
webservice_request.Headers.Add ("Authorization", oauth_header);
};
}
示例10: AsNotQuoted
public static string AsNotQuoted(IToken token)
{
if (token == null)
return null;
return AsNotQuoted(token.Text);
}
示例11: CaretToken
public CaretToken(IToken oldToken)
: base(oldToken)
{
this.channel = TokenConstants.DefaultChannel;
this._originalToken = oldToken;
this.type = CaretTokenType;
}
示例12: CreateSignature
public string CreateSignature(IToken token, Uri uri, string verb, string verifier = null, string callback = null)
{
var oAuthParameters = new OAuthParameters(
new ConsumerKey(token.ConsumerKey),
new TokenKey(token.TokenKey),
"HMAC-SHA1",
new DefaultTimestampSequence(),
new DefaultNonceSequence(),
string.Empty,
"1.0",
verifier,
token.Session, false, callback);
var signatureBaseString =
new SignatureBaseString(
new Request
{
Url = uri,
Verb = verb
},
oAuthParameters);
var signature = new HmacSha1().Sign(signatureBaseString, token.ConsumerSecret, token.TokenSecret);
oAuthParameters.SetSignature(signature);
return new AuthorizationHeader(oAuthParameters, string.Empty).Value;
}
示例13: GetText
/// <summary>
/// In our implementation, Token.TokenIndex always returns -1.
/// We can not insert all the intermediate tokens like Antlr does in the default implementation.
/// This method just returns the text of the starting and ending tokens.
/// </summary>
public override string GetText(IToken start, IToken stop)
{
if (start != null || stop != null)
{
if (start == stop)
{
return start.Text;
}
else
{
return start.Text + " ... " + stop.Text;
}
}
else if (start != null)
{
return start.Text + " ...";
}
else if (stop != null)
{
return "... " + stop.Text;
}
else
{
return String.Empty;
}
}
示例14: CreateToken
public static Token2 CreateToken(IToken token)
{
int length = token.StopIndex - token.StartIndex + 1;
int startPosition = token.StartIndex;
int endPosition = token.StopIndex;
switch (token.Type)
{
case Java6ColorizerLexer.DOUBLELITERAL:
case Java6ColorizerLexer.FLOATLITERAL:
return new NumericLiteralToken(token.Type, startPosition, endPosition);
case Java6ColorizerLexer.STRINGLITERAL:
return new StringLiteralToken(token.Type, startPosition, endPosition);
case Java6ColorizerLexer.BLOCK_COMMENT:
case Java6ColorizerLexer.LINE_COMMENT:
return new CommentLiteralToken(token.Type, startPosition, endPosition);
case Java6ColorizerLexer.IDENTIFIER:
if (Keywords.Contains(token.Text))
{
return new KeywordToken(token.Type, startPosition, endPosition);
}
return new IdentifierToken(token.Type, startPosition, endPosition);
}
//System.Diagnostics.Debug.WriteLine(string.Format("case JavaLexer.{0}:"), );
return new InvalidToken(token.Type, startPosition, endPosition);
}
示例15: TokenWrapper
public TokenWrapper(IToken token, string tokenName)
{
TokenName = tokenName;
Token = token;
Type = new TokenType {Type = token.Type};
tokenHashCode = Type.GetHashCode();
}