本文整理汇总了C#中TokenData类的典型用法代码示例。如果您正苦于以下问题:C# TokenData类的具体用法?C# TokenData怎么用?C# TokenData使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TokenData类属于命名空间,在下文中一共展示了TokenData类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: AssignMulti
public static Expr AssignMulti(bool declare, List<AssignExpr> exprs, TokenData token)
{
var exp = new AssignMultiExpr();
exp.Assignments = exprs;
SetupContext(exp, token);
return exp;
}
开发者ID:shuxingliu,项目名称:SambaPOS-3,代码行数:7,代码来源:Exprs.cs
示例2: Array
/// <summary>
/// Creates an array expression from the parameters supplied.
/// </summary>
/// <param name="items"></param>
/// <param name="token"></param>
/// <returns></returns>
public static Expr Array(List<Expr> items, TokenData token)
{
var exp = new ArrayExpr();
exp.Exprs = items;
SetupContext(exp, token);
return exp;
}
开发者ID:shuxingliu,项目名称:SambaPOS-3,代码行数:13,代码来源:Exprs.cs
示例3: Binary
/// <summary>
/// Creates a unary expression with symbol scope, context, script refernce set.
/// </summary>
/// <param name="name"></param>
/// <param name="token"></param>
/// <returns></returns>
public static Expr Binary(Expr left, Operator op, Expr right, TokenData token)
{
var exp = new BinaryExpr();
exp.Left = left;
exp.Op = op;
exp.Right = right;
SetupContext(exp, token);
return exp;
}
开发者ID:shuxingliu,项目名称:SambaPOS-3,代码行数:15,代码来源:Exprs.cs
示例4: Assign
/// <summary>
/// Creates a unary expression with symbol scope, context, script refernce set.
/// </summary>
/// <param name="name"></param>
/// <param name="token"></param>
/// <returns></returns>
public static Expr Assign(bool declare, Expr left, Expr right, TokenData token)
{
var exp = new AssignExpr();
exp.IsDeclaration = declare;
exp.VarExp = left;
exp.ValueExp = right;
SetupContext(exp, token);
return exp;
}
开发者ID:shuxingliu,项目名称:SambaPOS-3,代码行数:15,代码来源:Exprs.cs
示例5: ToConstDateTimeToken
/// <summary>
/// Builds a literal date expression from the inputs.
/// </summary>
/// <param name="date"></param>
/// <param name="time"></param>
/// <returns></returns>
public Token ToConstDateTimeToken(TokenData date, TokenData time)
{
var d = (DateTime)date.Token.Value;
var t = (TimeSpan) time.Token.Value;
var datetime = new DateTime(d.Year, d.Month, d.Day, t.Hours, t.Minutes, t.Seconds);
var text = date.Token.Text + " " + time.Token.Text;
var token = date.Token.Clone();
token.SetTextAndValue(text, datetime);
return token;
}
开发者ID:shuxingliu,项目名称:SambaPOS-3,代码行数:16,代码来源:MetaCompiler.cs
示例6: GenerateAccessToken
public string GenerateAccessToken(TokenData data)
{
if (data == null)
throw new ArgumentNullException("data");
var bytes = GetAccessTokenBytes(data);
var encryptedBytes = _encryptor.Encrypt(bytes);
return encryptedBytes.ToBase65();
}
开发者ID:naasir,项目名称:OAuth2Provider,代码行数:11,代码来源:OAuthIssuer.cs
示例7: Parse
/// <summary>
/// run step 123.
/// </summary>
/// <returns></returns>
public override Token[] Parse()
{
// print no quotes needed!
var takeoverToken = _lexer.LastTokenData;
int line = _lexer.State.Line;
int pos = _lexer.State.LineCharPosition;
var lineToken = _lexer.ReadLine(false);
var t = new TokenData() { Token = lineToken, Line = line, LineCharPos = pos };
_lexer.ParsedTokens.Add(takeoverToken);
_lexer.ParsedTokens.Add(t);
return new Token[] { takeoverToken.Token, lineToken };
}
开发者ID:neapolis,项目名称:SambaPOS-3,代码行数:16,代码来源:TakeoverPlugin.cs
示例8: Add
/// <summary>
/// Adds the counts from a collection.
/// Only tokens that exist in the destination will be added.
/// </summary>
public static TokenCollection Add(TokenCollection pDest, TokenCollection pSrc)
{
pSrc = Exclude(pDest._data.Tokens.Keys, pSrc);
TokenData copy = new TokenData(pDest._data);
foreach (KeyValuePair<string, int> pair in pSrc._data.Tokens)
{
copy.Tokens[pair.Key] += pSrc._data.Tokens[pair.Key];
}
return new TokenCollection(copy);
}
开发者ID:mancubus,项目名称:gems-bayesian,代码行数:16,代码来源:TokenCollection.cs
示例9: Parse
/// <summary>
/// Parses a function declaration statement.
/// This method is made public to allow other plugins to be used to allow different
/// words to represent "function" e.g. "def" instead of "function"
/// </summary>
/// <param name="token">The tokendata representing the starting token e.g. "function".</param>
/// <param name="expectToken">Whether or not to expect the token in tokenData.
/// If false, advances the token iterator</param>
/// <returns></returns>
public Expr Parse(TokenData token, bool expectToken)
{
var stmt = new FunctionDeclareExpr();
_parser.SetupContext(stmt.Function, token);
if (expectToken) _tokenIt.Expect(token.Token);
else _tokenIt.Advance();
// Function name.
var name = _tokenIt.ExpectId(true, true);
var aliases = new List<string>();
var nextToken = _tokenIt.NextToken;
List<string> argNames = null;
// Option 1: Wild card
if (nextToken.Token == Tokens.Multiply)
{
stmt.Function.Meta.HasWildCard = true;
nextToken = _tokenIt.Advance();
}
// Option 2: Aliases
else if (nextToken.Token == Tokens.Comma)
{
// Collect all function aliases
while (nextToken.Token == Tokens.Comma)
{
_tokenIt.Advance();
var alias = _tokenIt.ExpectId(true, true);
aliases.Add(alias);
nextToken = _tokenIt.NextToken;
}
if (aliases.Count > 0)
stmt.Function.Meta.Aliases = aliases;
}
// Get the parameters.
if (nextToken.Token == Tokens.LeftParenthesis)
{
_tokenIt.Expect(Tokens.LeftParenthesis);
argNames = _parser.ParseNames();
_tokenIt.Expect(Tokens.RightParenthesis);
}
stmt.Function.Meta.Init(name, argNames);
// Now parser the function block.
ParseBlock(stmt.Function);
return stmt;
}
开发者ID:GHLabs,项目名称:SambaPOS-3,代码行数:59,代码来源:FunctionPlugin.cs
示例10: ParseLine
/// <summary>
/// Parse the entire line.
/// </summary>
/// <param name="includeNewLine"></param>
/// <returns></returns>
protected Token[] ParseLine(bool includeNewLine)
{
// print no quotes needed!
var takeoverToken = _lexer.LastTokenData;
int line = _lexer.State.Line;
int pos = _lexer.State.LineCharPosition;
// This stops on the last char before the newline.
// So move forward one.
var lineToken = _lexer.ReadLine(false);
var t = new TokenData() { Token = lineToken, Line = line, LineCharPos = pos };
_lexer.ParsedTokens.Add(takeoverToken);
_lexer.ParsedTokens.Add(t);
return new Token[] { takeoverToken.Token, lineToken };
}
开发者ID:neapolis,项目名称:SambaPOS-3,代码行数:20,代码来源:LineReaderPlugin.cs
示例11: GetAuthorizationToken
public Token GetAuthorizationToken(long consumerId, long resourceOwnerId, string redirectUri)
{
var data = new TokenData
{
ConsumerId = consumerId,
Timestamp = DateTimeOffset.UtcNow.DateTime.Ticks,
ResourceOwnerId = resourceOwnerId,
RedirectUri = redirectUri
};
return new Token
{
AuthorizationToken = ServiceLocator.Issuer.GenerateAuthorizationToken(data),
ExpiresIn = ServiceLocator.Configuration.AuthorizationTokenExpirationLength
};
}
开发者ID:naasir,项目名称:OAuth2Provider,代码行数:16,代码来源:AuthorizationRequest.cs
示例12: GenerateAuthorizationToken
public string GenerateAuthorizationToken(TokenData data)
{
if (data == null)
throw new ArgumentNullException("data");
var bytes = GetAuthorizationTokenBytes(data);
var encryptedBytes = _encryptor.Encrypt(bytes);
var encryptedString = encryptedBytes.ToBase65();
if (data.RedirectUri.HasValue())
encryptedString += "|" + _encryptor.Encrypt(Encoding.ASCII.GetBytes(data.RedirectUri)).ToBase65();
return encryptedString;
}
开发者ID:naasir,项目名称:OAuth2Provider,代码行数:16,代码来源:OAuthIssuer.cs
示例13: ParseData
public static void ParseData(ParseNode node)
{
var tokenData = node.Children.First();
var defineText = tokenData.Content.Remove(0, "#property ".Length);
var lexer = new Mq4Lexer();
var defineTokens = lexer.BuildTextTokens(defineText);
var nodes = defineTokens.Select(token => token.BuildTerminalNode()).ToList();
var states = new CleanupAstNodeStates(nodes);
var assemblyOfAttributes = typeof(indicator_color1Attribute).Assembly;
var fullTypeName = string.Format("Mql2Fdk.Attributes.{0}Attribute", states[0].Content);
var fullTypeNameReduced = string.Format("Mql2Fdk.Attributes.{0}", states[0].Content);
var getTypeofAttribute =
assemblyOfAttributes.GetType(fullTypeName)
?? assemblyOfAttributes.GetType(fullTypeNameReduced);
bool needsQuotes = false;
var typeName = getTypeofAttribute!=null
? ComputeTypenameFromReflection(getTypeofAttribute, states, ref needsQuotes)
: ComputeTypeFromStatements(states, ref needsQuotes);
var variableToken = states.MappedNodes[0];
var valueToken = states.Count != 1
? states.MappedNodes[1]
: new TokenData(0, 0, TokenKind.Int, "1").BuildTerminalNode();
if (needsQuotes)
{
var finalTokenData = valueToken.GetTokenData();
finalTokenData.Token = TokenKind.QuotedString;
finalTokenData.Content = string.Format("\"{0}\"", finalTokenData.Content);
}
node.Children.Clear();
var insertTokenType = new TokenData(0, 0, TokenKind.TypeName, typeName);
var buildTerminalToken = insertTokenType.BuildTerminalNode();
node.Add(buildTerminalToken);
node.AddTerminalToken(new TokenData(0, 0, TokenKind.Space, " "));
node.Add(variableToken);
node.AddTerminalToken(new TokenData(0, 0, TokenKind.Assign, "="));
node.Add(valueToken);
var colon = new TokenData(0, 0, TokenKind.SemiColon, ";").BuildTerminalNode();
node.Children.Add(colon);
}
开发者ID:ifzz,项目名称:FDK,代码行数:45,代码来源:SharpPropertyRule.cs
示例14: Authorize
public TokenData Authorize(string username, string password)
{
BusinessPrincipal.Login(username, password);
var result = new TokenData();
var token = new Token();
var tokenRepository = new TokenRepository();
token.Key = Guid.NewGuid().ToString().ToUpper();
token.UserName = username;
token.CreatedDate = DateTime.Now;
token.ExpirationDate = DateTime.Now.AddMinutes(30);
tokenRepository.AddToken(token);
result.Key = token.Key;
return result;
}
开发者ID:mattruma,项目名称:epiworx-csla,代码行数:19,代码来源:Service.cs
示例15: AuthorizeRequest
protected virtual void AuthorizeRequest(ActionExecutingContext filterContext)
{
var isAuthorized = false;
try
{
var resourceRequest = new ResourceRequest(new HttpRequestBaseRequest(Request), _serviceLocator);
isAuthorized = resourceRequest.Authorize();
TokenData = _serviceLocator.Issuer.DecodeAccessToken(resourceRequest.AccessToken);
}
catch (OAuthException)
{
}
if (isAuthorized)
return;
throw new UnauthorizedAccessException();
}
开发者ID:vishal-h,项目名称:OAuth2Provider,代码行数:20,代码来源:SecureController.cs
示例16: Authorize
public Token Authorize(IOAuthRequest request)
{
_logger.Debug("Authorizing refresh token request");
if (request.ContentType != ContentType.FormEncoded)
throw new OAuthException(ErrorCode.InvalidRequest, "Invalid content type.");
//Make sure consumer is valid
var consumer = _consumerRepository.GetByClientId(request.ClientId);
if (consumer == null)
throw new OAuthException(ErrorCode.InvalidClient, "Client credentials are invalid");
if (consumer.Secret != request.ClientSecret)
throw new OAuthException(ErrorCode.InvalidClient, "User credentials are invalid");
var refreshToken = request.RefreshToken;
if (string.IsNullOrWhiteSpace(refreshToken))
throw new OAuthException(ErrorCode.InvalidRequest, "Refresh token is invalid");
var tokenData = _issuer.DecodeRefreshToken(refreshToken);
if (tokenData.ConsumerId != consumer.ConsumerId)
throw new OAuthException(ErrorCode.UnauthorizedClient, "Refresh token is invalid");
if (!_resourceOwnerRepository.IsConsumerApproved(tokenData.ResourceOwnerId, tokenData.ConsumerId))
throw new OAuthException(ErrorCode.UnauthorizedClient, "Unauthorized access");
var newTokenData = new TokenData
{
ConsumerId = consumer.ConsumerId,
ResourceOwnerId = tokenData.ResourceOwnerId,
Timestamp = DateTimeOffset.UtcNow.DateTime.Ticks
};
return new Token
{
AccessToken = _issuer.GenerateAccessToken(newTokenData),
ExpiresIn = _configuration.AccessTokenExpirationLength,
RefreshToken = _issuer.GenerateRefreshToken(newTokenData)
};
}
开发者ID:chrismcv,项目名称:OAuth2Provider,代码行数:41,代码来源:RefreshTokenRequestAuthorizer.cs
示例17: TokenDataEqualityTest
public void TokenDataEqualityTest()
{
var dateTimeOffset = DateTimeOffset.Now;
var left = new TokenData
{
Client = "client",
ExpiresAt = dateTimeOffset,
Token = "token"
};
var right = new TokenData
{
Client = "client",
ExpiresAt = dateTimeOffset,
Token = "token"
};
Assert.AreEqual(left.GetHashCode(), right.GetHashCode());
Assert.AreEqual(left, right);
}
开发者ID:AppSpaceIT,项目名称:ParticleIoNet,代码行数:21,代码来源:TokenDataTests.cs
示例18: Authorize
public Token Authorize(IOAuthRequest request)
{
_logger.Debug("Authorizing password token request");
if (request.ContentType != ContentType.FormEncoded)
throw new OAuthException(ErrorCode.InvalidRequest, "Invalid content type.");
//Make sure consumer is valid
var consumer = _serviceLocator.ConsumerRepository.GetByClientId(request.ClientId);
if (consumer == null)
throw new OAuthException(ErrorCode.InvalidClient, "Client credentials are invalid");
if (consumer.Secret != request.ClientSecret)
throw new OAuthException(ErrorCode.InvalidClient, "User credentials are invalid");
//Make sure resource owner is valid
var resourceOwner = _serviceLocator.ResourceOwnerRepository.GetByUsername(consumer.ConsumerId, request.Username);
if (resourceOwner == null)
throw new OAuthException(ErrorCode.InvalidClient, "User credentials are invalid");
if (!_serviceLocator.PasswordHasher.CheckPassword(request.Password, resourceOwner.Password))
throw new OAuthException(ErrorCode.InvalidClient, "User credentials are invalid");
//Make sure consumer is approved by resource owner
_serviceLocator.ResourceOwnerRepository.ApproveConsumer(resourceOwner.ResourceOwnerId, consumer.ConsumerId);
var data = new TokenData
{
ConsumerId = consumer.ConsumerId,
ResourceOwnerId = resourceOwner.ResourceOwnerId,
Timestamp = DateTimeOffset.UtcNow.DateTime.Ticks
};
return new Token
{
AccessToken = _serviceLocator.Issuer.GenerateAccessToken(data),
RefreshToken = _serviceLocator.Issuer.GenerateRefreshToken(data),
ExpiresIn = _serviceLocator.Configuration.AccessTokenExpirationLength
};
}
开发者ID:joeyburgett,项目名称:OAuth2Provider,代码行数:40,代码来源:PasswordTokenRequestAuthorizer.cs
示例19: Authorize
public Token Authorize(IOAuthRequest request)
{
_logger.Debug("Authorizing client credentials token request");
//Make sure consumer is valid
var consumer = _serviceLocator.ConsumerRepository.GetByClientId(request.ClientId);
if (consumer == null || !consumer.Secret.Equals(request.ClientSecret,StringComparison.OrdinalIgnoreCase))
throw new OAuthException(ErrorCode.InvalidClient, "Client credentials are invalid");
var data = new TokenData
{
ConsumerId = consumer.ConsumerId,
Timestamp = DateTimeOffset.UtcNow.DateTime.Ticks
};
return new Token
{
AccessToken = _serviceLocator.Issuer.GenerateAccessToken(data),
RefreshToken = _serviceLocator.Issuer.GenerateRefreshToken(data),
ExpiresIn = _serviceLocator.Configuration.AccessTokenExpirationLength
};
}
开发者ID:naasir,项目名称:OAuth2Provider,代码行数:22,代码来源:ClientCredentialsTokenRequestAuthorizer.cs
示例20: Authorize
public Token Authorize(Request.IOAuthRequest request)
{
_logger.Debug("Authorizing authorization code request");
var grantType = request.GrantType;
if (!grantType.HasValue())
throw new OAuthException(ErrorCode.InvalidRequest, "Parameter grant_type is missing");
if (request.GrantType != GrantType.AuthorizationCode)
throw new OAuthException(ErrorCode.InvalidGrant, "The specified grant_type is not supported");
var code = request.AuthorizationCode;
if (!code.HasValue())
throw new OAuthException(ErrorCode.InvalidRequest, "Parameter code is missing");
var tokenData = _issuer.DecodeAuthorizationToken(code);
if ((DateTime.UtcNow - new DateTime(tokenData.Timestamp, DateTimeKind.Utc)).TotalSeconds > _configuration.AuthorizationTokenExpirationLength)
throw new OAuthException(ErrorCode.InvalidRequest, "Authorization code has expired");
if (tokenData.RedirectUri != request.RedirectUri)
throw new OAuthException(ErrorCode.InvalidRequest, "The specified redirect_uri is invalid");
var newTokenData = new TokenData
{
ConsumerId = tokenData.ConsumerId,
ResourceOwnerId = tokenData.ResourceOwnerId,
Timestamp = DateTime.UtcNow.Ticks
};
return new Token
{
AccessToken = _issuer.GenerateAccessToken(newTokenData),
ExpiresIn = _configuration.AccessTokenExpirationLength,
RefreshToken = _issuer.GenerateRefreshToken(newTokenData),
RedirectsUri = request.RedirectUri
};
}
开发者ID:naasir,项目名称:OAuth2Provider,代码行数:37,代码来源:AuthorizationCodeAuthorizer.cs
注:本文中的TokenData类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论