本文整理汇总了C#中ITokenizer类的典型用法代码示例。如果您正苦于以下问题:C# ITokenizer类的具体用法?C# ITokenizer怎么用?C# ITokenizer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ITokenizer类属于命名空间,在下文中一共展示了ITokenizer类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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"];
};
}
开发者ID:rjonker1,项目名称:lightstone-data-platform,代码行数:31,代码来源:AuthModule.cs
示例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);
};
}
开发者ID:alana1,项目名称:NancySamples,代码行数:30,代码来源:AuthModule.cs
示例3: AssertTokens
public static void AssertTokens(ITokenizer tokenizer, params Token[] tokens)
{
foreach (Token expected in tokens)
{
Assertion.AssertEquals(expected, tokenizer.NextToken());
}
}
开发者ID:bamboo,项目名称:Bamboo.Prevalence,代码行数:7,代码来源:TokenAssertions.cs
示例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
};
};
}
开发者ID:DNIDNL,项目名称:hadouken,代码行数:35,代码来源:AuthModule.cs
示例5: TokenizedNameProvider
public TokenizedNameProvider(ITokenizer tokenizer, List<ITokenTransformer> tokenTransformers,
List<IStringNameOptimizer> optimizers)
{
_tokenizer = tokenizer;
_tokenTransformers = tokenTransformers;
_optimizers = optimizers;
}
开发者ID:sia-s,项目名称:NEDupRemover,代码行数:7,代码来源:TokenizedNameProvider.cs
示例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!";
};
}
开发者ID:jbattermann,项目名称:Nancy,代码行数:35,代码来源:AuthModule.cs
示例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;
}
开发者ID:Bigjono,项目名称:sqlformat,代码行数:29,代码来源:ParameterSubstituter.cs
示例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
};
};
}
开发者ID:KyulingLee,项目名称:hadouken,代码行数:28,代码来源:AuthModule.cs
示例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;
}
开发者ID:TheModMaker,项目名称:ModMaker.Lua,代码行数:39,代码来源:PlainParser.cs
示例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!";
};
}
开发者ID:joeyulivecn,项目名称:NancyDemo,代码行数:30,代码来源:AuthModule.cs
示例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;
}
开发者ID:juntalis,项目名称:CHeaderGenerator,代码行数:11,代码来源:CLexer.cs
示例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;
}
开发者ID:ventil8,项目名称:Nop.Plugin.Misc.FreeSample,代码行数:30,代码来源:HomeInstallationQuoteController.cs
示例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;
}
开发者ID:mandocaesar,项目名称:Mesinku,代码行数:29,代码来源:WorkflowMessageService.cs
示例14: TokenizerProcessingDecorator
public TokenizerProcessingDecorator(ITokenizer tokenizer, Preprocessor preprocessor, Postprocessor postprocessor)
{
this.tokenizer = tokenizer;
this.preprocessor = preprocessor;
this.postprocessor = postprocessor;
}
开发者ID:bytefish,项目名称:TinyCsvParser,代码行数:7,代码来源:TokenizerProcessingDecorator.cs
示例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;
}
开发者ID:Console-Byte,项目名称:mobsocial,代码行数:29,代码来源:MobSocialMessageService.cs
示例16: AuthModule
public AuthModule(ITokenizer tokenizer)
: base("/auth")
{
Options["/"] = o =>
{
return HttpStatusCode.OK;
};
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
};
};
}
开发者ID:duhaly,项目名称:NancyFxConsole,代码行数:28,代码来源:AuthModule.cs
示例17: WorkflowMessageService
public WorkflowMessageService(IMessageTemplateService messageTemplateService,
IQueuedEmailService queuedEmailService,
ILanguageService languageService,
ITokenizer tokenizer,
IEmailAccountService emailAccountService,
IMessageTokenProvider messageTokenProvider,
IStoreService storeService,
IStoreContext storeContext,
EmailAccountSettings emailAccountSettings,
IEventPublisher eventPublisher,
ISMSSender smsSender,
SMSSettings smsSettings)
{
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._smsSender = smsSender;
this._smsSettings = smsSettings;
}
开发者ID:minuzZ,项目名称:zelectroshop,代码行数:26,代码来源:WorkflowMessageService.cs
示例18: AuthModule
public AuthModule(ITokenizer tokenizer, Users users)
: base("/auth")
{
Post["/"] = x =>
{
var request = this.Bind<AuthRequest>();
if (string.IsNullOrEmpty(request.Identifier))
{
return HttpStatusCode.Unauthorized;
}
var user = users.ValidateUsernameOrEmail(request.Identifier, request.Password);
if (user == null)
{
return HttpStatusCode.Unauthorized;
}
var userIdentity = new UserIdentity(user);
var token = tokenizer.Tokenize(userIdentity, Context);
return new
{
Token = token,
Username = user.Username,
UserId = user.Id
};
};
Get["/"] = _ =>
{
this.RequiresAuthentication();
return Context.CurrentUser;
};
}
开发者ID:ryascl,项目名称:design-challenge-server-clr,代码行数:35,代码来源:AuthModule.cs
示例19: GetWordFrequency
/// <summary>
/// Gets a Hashtable of words and integers representing the number of each word.
/// </summary>
/// <param name="input">The string to get the word frequency of.</param>
/// <param name="caseSensitive">True if words should be treated as separate if they have different casing.</param>
/// <param name="tokenizer">A instance of ITokenizer.</param>
/// <param name="stopWordProvider">An instance of IStopWordProvider.</param>
/// <returns></returns>
public static Hashtable GetWordFrequency(string input, bool caseSensitive, ITokenizer tokenizer, IStopWordProvider stopWordProvider)
{
string convertedInput = input;
if (!caseSensitive)
convertedInput = input.ToLower();
string[] words = tokenizer.Tokenize(convertedInput);
Array.Sort(words);
string[] uniqueWords = GetUniqueWords(words);
Hashtable result = new Hashtable();
for (int i = 0; i < uniqueWords.Length; i++)
{
if (stopWordProvider == null || (IsWord(uniqueWords[i]) && !stopWordProvider.IsStopWord(uniqueWords[i])))
{
if (result.ContainsKey(uniqueWords[i]))
result[uniqueWords[i]] = (int)result[uniqueWords[i]] + CountWords(uniqueWords[i], words);
else
result.Add(uniqueWords[i], CountWords(uniqueWords[i], words));
}
}
return result;
}
开发者ID:bonchovylkov,项目名称:Sport-Classifier,代码行数:33,代码来源:Utilities.cs
示例20: SparseMatcher
public SparseMatcher(ISparseDistance distance, IReworder reworder, IReader reader, ITokenizer tokenizer, string encyclopediaFilePath)
{
_distance = distance;
_reader = reader;
_reworder = reworder;
_tokenizer = tokenizer;
_encyclopediaFilePath = encyclopediaFilePath;
}
开发者ID:turboNinja2,项目名称:Rob-The-Robot,代码行数:8,代码来源:SparseMatcher.cs
注:本文中的ITokenizer类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论