本文整理汇总了C#中ITokenizer类的典型用法代码示例。如果您正苦于以下问题:C# ITokenizer类的具体用法?C# ITokenizer怎么用?C# ITokenizer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ITokenizer类属于命名空间,在下文中一共展示了ITokenizer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AuthModule
public AuthModule(IUserManagementApiClient client, ITokenizer tokenizer)
{
Get["/login"] = parameters =>
{
return View["Index"];
};
Get["/logout"] = parameters =>
{
return this.Logout("/");
};
Post["/login"] = parameters =>
{
var model = this.Bind<AuthModel>();
var token = client.Post("", "/login", null, null, new[] { new KeyValuePair<string, string>("Username", model.Username), new KeyValuePair<string, string>("Password", model.Password) });
var userIdentity = tokenizer.Detokenize(token, Context, new DefaultUserIdentityResolver());
Context.CurrentUser = userIdentity;
return token;
};
Get["/forgotPassword/{username}"] = _ =>
{
ViewBag.Message = client.Put("", UserManagementApiRoute.User.RequestResetPassword, new[] { new KeyValuePair<string, string>("username", _.username + "") }, null, null);
return View["Login"];
};
}
示例2: AuthModule
public AuthModule(ITokenizer tokenizer, IAuthService authService)
: base("auth")
{
this.tokenizer = tokenizer;
this.authService = authService;
Post["/token"] = x =>
{
var request = this.CustomBindAndValidate<AuthenticateUserRequest>();
var identity = GetUserIdentity(request);
var response = GetAuthenticateResponse(identity);
return Negotiate
.WithStatusCode(HttpStatusCode.OK)
.WithModel(response);
};
Post["/register"] = x =>
{
var request = this.CustomBindAndValidate<RegisterUserRequest>();
authService.Register(request);
var response = new RegisterUserResponse();
return Negotiate
.WithStatusCode(HttpStatusCode.OK)
.WithModel(response);
};
}
示例3: AssertTokens
public static void AssertTokens(ITokenizer tokenizer, params Token[] tokens)
{
foreach (Token expected in tokens)
{
Assertion.AssertEquals(expected, tokenizer.NextToken());
}
}
示例4: AuthModule
public AuthModule(ILogger<AuthModule> logger,
IUserManager userManager,
ITokenizer tokenizer)
: base("auth")
{
Get["/setup"] = _ => !userManager.HasUsers();
Post["/login"] = _ =>
{
var userData = this.Bind<UserDto>();
// First login creates user
if (!userManager.HasUsers())
{
logger.Info("Creating user account {UserName}.", userData.UserName);
userManager.CreateUser(userData.UserName, userData.Password);
}
var user = userManager.GetUser(userData.UserName, userData.Password);
if (user == null)
{
logger.Warn("Invalid username/password: {UserName}.", userData.UserName);
return HttpStatusCode.Unauthorized;
}
var identity = new UserIdentity(user.UserName, user.Claims);
var token = tokenizer.Tokenize(identity, Context);
return new
{
Token = token
};
};
}
示例5: TokenizedNameProvider
public TokenizedNameProvider(ITokenizer tokenizer, List<ITokenTransformer> tokenTransformers,
List<IStringNameOptimizer> optimizers)
{
_tokenizer = tokenizer;
_tokenTransformers = tokenTransformers;
_optimizers = optimizers;
}
示例6: AuthModule
public AuthModule(ITokenizer tokenizer)
: base("/auth")
{
Post["/"] = x =>
{
var userName = (string)this.Request.Form.UserName;
var password = (string)this.Request.Form.Password;
var userIdentity = UserDatabase.ValidateUser(userName, password);
if (userIdentity == null)
{
return HttpStatusCode.Unauthorized;
}
var token = tokenizer.Tokenize(userIdentity, Context);
return new
{
Token = token,
};
};
Get["/validation"] = _ =>
{
this.RequiresAuthentication();
return "Yay! You are authenticated!";
};
Get["/admin"] = _ =>
{
this.RequiresClaims(new[] { "admin" });
return "Yay! You are authorized!";
};
}
示例7: ProcessParameter
private string ProcessParameter(ITokenizer tokenizer, string parameterName)
{
// the following code produces a parameter that supports Guids. For unknown reasons, NH
// is supplying the parameter value as an unquoted set of alpha numerics, so, here they are processed
// until the next token is NOT a dash
int tokenCount = 0;
string token = "";
//string regexDateFormat = GetDateFormatRegex();
tokenizer.SkipWhiteSpace = false;
do
{
if (tokenizer.Current.Type != TokenType.BlockedText)
{
token +=
// TODO: the code below will not work until the parser can retain embedded comments
//String.Format("/* {0} */ ", parameterName) +
tokenizer.Current.Value;
if (tokenizer.Current.Type != TokenType.WhiteSpace)
tokenCount++;
}
tokenizer.ReadNextToken();
}
while (tokenizer.HasMoreTokens && !tokenizer.IsNextToken(Constants.Comma));
tokenizer.SkipWhiteSpace = true;
return tokenCount > 1 && !token.StartsWith("'") ? String.Format("'{0}'", token.Trim().ToUpper()) : token;
}
示例8: AuthModule
public AuthModule(IConfiguration configuration, IAuthenticationManager authenticationManager, ITokenizer tokenizer)
: base("auth")
{
Get["/setup"] = _ => string.IsNullOrEmpty(configuration.UserName);
Post["/login"] = _ =>
{
var loginParameters = this.Bind<LoginParameters>();
if (string.IsNullOrEmpty(configuration.UserName))
{
SetAuth(configuration, loginParameters);
}
if (!authenticationManager.IsValid(loginParameters.UserName, loginParameters.Password))
{
return HttpStatusCode.Unauthorized;
}
var identity = new UserIdentity(loginParameters.UserName, null);
var token = tokenizer.Tokenize(identity, Context);
return new
{
Token = token
};
};
}
示例9: Parse
/// <summary>
/// Parses the given Lua code into a IParseItem tree.
/// </summary>
/// <param name="input">The Lua code to parse.</param>
/// <param name="name">The name of the chunk, used for exceptions.</param>
/// <param name="hash">The hash of the Lua code, can be null.</param>
/// <returns>The code as an IParseItem tree.</returns>
/// <remarks>Simply calls Parse(Tokenizer, string, bool) with force:false.</remarks>
public IParseItem Parse(ITokenizer input, string name, string hash)
{
if (input == null)
throw new ArgumentNullException("input");
// check if the chunk is already loaded
if (UseCache)
{
lock (_lock)
{
if (_cache != null && hash != null && _cache.ContainsKey(hash))
return _cache[hash];
}
}
// parse the chunk
Token temp = new Token();
IParseItem read = ReadBlock(input, ref temp);
Token end = Read(input, ref temp);
if (end.Value != null)
throw new SyntaxException(string.Format(Resources.TokenEOF, end.Value), input.Name, end);
// store the loaded chunk in the cache
lock (_lock)
{
if (_cache != null && hash != null)
_cache[hash] = read;
}
return read;
}
示例10: AuthModule
public AuthModule(ITokenizer tokenizer)
: base("/auth")
{
Post["/"] = x =>
{
var userName = this.Request.Form.UserName;
var password = this.Request.Form.Password;
var userIdentity = new UserIdentity();
var token = tokenizer.Tokenize(userIdentity, Context);
return new
{
Token = token
};
};
Get["/validation"] = _ =>
{
this.RequiresAuthentication();
return "Yay! You are authenticated!";
};
Get["/admin"] = _ =>
{
this.RequiresClaims(new[] { "admin" });
return "Yay! You are authorized!";
};
}
示例11: CLexer
/// <summary>
/// Constructs a new lexer for the C language.
/// </summary>
/// <param name="tokenizer">An object to return generic tokens.</param>
public CLexer(ITokenizer<TokenType> tokenizer)
{
if (tokenizer == null)
throw new ArgumentNullException("tokenizer");
this.localTokenizer = tokenizer;
}
示例12: HomeInstallationQuoteController
public HomeInstallationQuoteController(
IWorkContext workContext,
ISettingService settingService,
IGenericAttributeService genericAttributeService,
ILocalizationService localizationService,
IMessageTokenProvider messageTokenProvider,
IEmailAccountService emailAccountService,
IEventPublisher eventPublisher,
IMessageTemplateService messageTemplateService,
ITokenizer tokenizer,
IQueuedEmailService queuedEmailService,
IProductService productService,
CaptchaSettings captchaSettings,
EmailAccountSettings emailAccountSettings)
{
_workContext = workContext;
_settingService = settingService;
_genericAttributeService = genericAttributeService;
_localizationService = localizationService;
_messageTokenProvider = messageTokenProvider;
_emailAccountService = emailAccountService;
_eventPublisher = eventPublisher;
_messageTemplateService = messageTemplateService;
_tokenizer = tokenizer;
_queuedEmailService = queuedEmailService;
_productService = productService;
_captchaSettings = captchaSettings;
_emailAccountSettings = emailAccountSettings;
}
示例13: WorkflowMessageService
public WorkflowMessageService(
IMessageTemplateService messageTemplateService,
IQueuedEmailService queuedEmailService,
ILanguageService languageService,
ITokenizer tokenizer,
IEmailAccountService emailAccountService,
IMessageTokenProvider messageTokenProvider,
IStoreService storeService,
IStoreContext storeContext,
EmailAccountSettings emailAccountSettings,
IEventPublisher eventPublisher,
IWorkContext workContext,
HttpRequestBase httpRequest,
IDownloadService downloadServioce)
{
this._messageTemplateService = messageTemplateService;
this._queuedEmailService = queuedEmailService;
this._languageService = languageService;
this._tokenizer = tokenizer;
this._emailAccountService = emailAccountService;
this._messageTokenProvider = messageTokenProvider;
this._storeService = storeService;
this._storeContext = storeContext;
this._emailAccountSettings = emailAccountSettings;
this._eventPublisher = eventPublisher;
this._workContext = workContext;
this._httpRequest = httpRequest;
this._downloadServioce = downloadServioce;
}
示例14: TokenizerProcessingDecorator
public TokenizerProcessingDecorator(ITokenizer tokenizer, Preprocessor preprocessor, Postprocessor postprocessor)
{
this.tokenizer = tokenizer;
this.preprocessor = preprocessor;
this.postprocessor = postprocessor;
}
示例15: MobSocialMessageService
public MobSocialMessageService(IMessageTemplateService messageTemplateService,
IStoreService storeService, IMessageTokenProvider messageTokenProvider,
ILanguageService languageService,
IStoreContext storeContext,
IEventPublisher eventPublisher,
ITokenizer tokenizer, IQueuedEmailService queuedEmailService,
IEmailAccountService emailAccountService,
EmailAccountSettings emailAccountSettings,
ILocalizationService localizationService,
MessageTemplatesSettings messageTemplateSettings,
CatalogSettings catalogSettings,
IProductAttributeParser productAttributeParser, IWorkContext workContext)
{
_messageTemplateService = messageTemplateService;
_storeService = storeService;
_messageTokenProvider = messageTokenProvider;
_languageService = languageService;
_storeContext = storeContext;
_eventPublisher = eventPublisher;
_tokenizer = tokenizer;
_queuedEmailService = queuedEmailService;
_emailAccountService = emailAccountService;
_emailAccountSettings = emailAccountSettings;
_localizationService = localizationService;
_messageTemplateSettings = messageTemplateSettings;
_catalogSettings = catalogSettings;
_productAttributeParser = productAttributeParser;
_workContext = workContext;
}