本文整理汇总了C#中IHandler.Handle方法的典型用法代码示例。如果您正苦于以下问题:C# IHandler.Handle方法的具体用法?C# IHandler.Handle怎么用?C# IHandler.Handle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IHandler
的用法示例。
在下文中一共展示了IHandler.Handle方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UsersModule
public UsersModule(
IHandler<GetCurrentUserRequest, User> getCurrentUserHandler,
IHandler<LoginRequest, bool> loginHandler,
IHandler<LogoutRequest, bool> logoutHandler,
INancySecurityContextFactory nancySecurityContextFactory)
{
if (getCurrentUserHandler == null) throw new ArgumentNullException("getCurrentUserHandler");
if (loginHandler == null) throw new ArgumentNullException("loginHandler");
if (logoutHandler == null) throw new ArgumentNullException("logoutHandler");
if (nancySecurityContextFactory == null) throw new ArgumentNullException("nancySecurityContextFactory");
Get["api/user", true] = async (parameters, cancellationToken) => {
this.RequiresAuthentication();
return await getCurrentUserHandler.Handle(this.Bind(() =>
new GetCurrentUserRequest {
SecurityContext = nancySecurityContextFactory.Create(Context)
}));
};
Post["api/user/login", true] = async (parameters, cancellationToken) => await loginHandler.Handle(this.Bind(() => {
var loginRequest = this.Bind<LoginRequest>();
return new LoginRequest {
SecurityContext = nancySecurityContextFactory.Create(Context),
Login = loginRequest?.Login,
Password = loginRequest?.Password
};
}));
Post["api/user/logout", true] = async (parameters, cancellationToken) => {
this.RequiresAuthentication();
return await logoutHandler.Handle(this.Bind(() =>
new LogoutRequest {
SecurityContext = nancySecurityContextFactory.Create(Context)
}));
};
}
示例2: SendRequests
private static void SendRequests(IHandler cor)
{
cor.Handle(new Request("all_small_letters_request"));
cor.Handle(new Request("FirstIsBigRequest"));
cor.Handle(new Request(null));
}