本文整理汇总了C#中ICommandHandler类的典型用法代码示例。如果您正苦于以下问题:C# ICommandHandler类的具体用法?C# ICommandHandler怎么用?C# ICommandHandler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ICommandHandler类属于命名空间,在下文中一共展示了ICommandHandler类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MatchCommands
private static IEnumerable<Match> MatchCommands(CommandParameters parameters, int argCount, CommandHandlerDescriptor descriptor, ICommandHandler handler)
{
foreach (var commandDescriptor in descriptor.Commands)
{
foreach (var name in commandDescriptor.Names)
{
var names = name.Split(' ');
if (parameters.Arguments.Take(argCount).SequenceEqual(names, StringComparer.OrdinalIgnoreCase))
{
yield return new Match
{
Context = new CommandContext
{
Arguments = parameters.Arguments.Skip(names.Count()),
Command = string.Join(" ", names),
CommandDescriptor = commandDescriptor,
Input = parameters.Input,
Output = parameters.Output,
Switches = parameters.Switches,
},
CommandHandler = handler
};
}
}
}
}
示例2: CommandController
public CommandController(
ICommandHandler<CreateProductCommand> createProductCommandHandler,
ICommandHandler<CreateProductVersionCommand> createProductVersionCommandHandler)
{
this.createProductCommandHandler = createProductCommandHandler;
this.createProductVersionCommandHandler = createProductVersionCommandHandler;
}
示例3: DocumentWindow
public DocumentWindow(IServiceProvider serviceProvider, Microsoft.Matrix.Core.Documents.Document document)
: base(serviceProvider)
{
if (document == null)
{
throw new ArgumentNullException("document");
}
this._document = document;
try
{
base.SuspendLayout();
this.InitializeUserInterface();
this._documentView = this.CreateDocumentView();
}
finally
{
base.ResumeLayout(true);
}
this._documentView.DocumentChanged += new EventHandler(this.OnDocumentViewDocumentChanged);
this._viewCommandHandler = this._documentView as ICommandHandler;
this._viewToolboxClient = this._documentView as IToolboxClient;
this._viewSelectionContainer = this._documentView as ISelectionContainer;
IDesigner designer = ((IDesignerHost) serviceProvider.GetService(typeof(IDesignerHost))).GetDesigner(document);
this._designerCommandHandler = designer as ICommandHandler;
this._contextCommandHandler = this._document.ProjectItem.Project;
this.UpdateCaption();
}
示例4: Register
public void Register(ICommandHandler handler)
{
if (handler == null) throw new ArgumentNullException(nameof(handler));
var supportedCommandTypes = handler.GetType()
.GetInterfaces()
.Where(iface => iface.IsGenericType && iface.GetGenericTypeDefinition() == typeof(ICommandHandler<>))
.Select(iface => iface.GetGenericArguments()[0])
.ToList();
var registeredType = _handlers.Keys.FirstOrDefault(x => supportedCommandTypes.Contains(x));
if (registeredType != null)
{
var commands = String.Join(", ", supportedCommandTypes.Select(x => x.FullName));
var registeredHandler = _handlers[registeredType];
var message = $"The command(s) ('{commands}') handled by the received handler ('{handler}') already has a registered handler ('{registeredHandler}').";
Logging.Darjeel.TraceError(message);
throw new ArgumentException(message);
}
foreach (var commandType in supportedCommandTypes)
{
_handlers.Add(commandType, handler);
}
}
示例5: CommandExampleController
public CommandExampleController(
ICommandHandler<CreateOrderCommand> createOrderhandler,
ICommandHandler<ShipOrderCommand> shipOrderhandler)
{
this.createOrderhandler = createOrderhandler;
this.shipOrderhandler = shipOrderhandler;
}
示例6: ServiceConsumer
public ServiceConsumer(
ICommandHandler<AddDelegateCommand> addHandler,
ICommandHandler<UpdateDelegateCommand> updateHandler)
{
this.addHandler = addHandler;
this.updateHandler = updateHandler;
}
示例7: OrderApiService
public OrderApiService(
ICommandHandler<MakeOrderCommand> commmHandler,
IOrderRepository repository)
{
_commmHandler = commmHandler;
_repository = repository;
}
示例8: MatchCommands
private static IEnumerable<Match> MatchCommands(CommandParameters parameters, int argCount, CommandHandlerDescriptor descriptor, ICommandHandler handler)
{
foreach (var commandDescriptor in descriptor.Commands)
{
foreach (var name in commandDescriptor.Names)
{
var names = name.Split(' ');
// We check here number of arguments a command can recieve against
// arguments provided for the command to identify the correct command
// and avoid matching multiple commands.
if(commandDescriptor.MethodInfo.GetParameters().Length == argCount - names.Count())
{
names = parameters.Arguments.ToArray();
}
if (parameters.Arguments.Take(argCount).SequenceEqual(names, StringComparer.OrdinalIgnoreCase))
{
yield return new Match
{
Context = new CommandContext
{
Arguments = parameters.Arguments.Skip(name.Split(' ').Count()),
Command = string.Join(" ", names),
CommandDescriptor = commandDescriptor,
Input = parameters.Input,
Output = parameters.Output,
Switches = parameters.Switches,
},
CommandHandler = handler
};
}
}
}
}
示例9: MainCommandHandlerChain
public MainCommandHandlerChain(
IConsole console,
ICommandHandler[] commandHandlers)
{
_console = console;
_commandHandlers = commandHandlers;
}
示例10: ShellViewModel
public ShellViewModel( ITimerHandler timerHandler,
IPlaybackHandler playbackHandler,
ICommandHandler commandHandler )
{
this.TimerHandler = timerHandler;
this.playbackHandler = playbackHandler;
this.TimerHandler.TimedEventCompleted += ( se, ea ) =>
{
this.playbackHandler.PlayTimedEventComplete( se as TimedEvent );
};
commandHandler.CommandRecognized += ( se, ea ) =>
{
this.playbackHandler.PlayCommandAccepted();
var command = se as Command;
if ( command.Verb == "time" )
{
this.TimerHandler.Start( command.Noun );
}
else if ( command.Verb == "clear" )
{
this.TimerHandler.Clear( command.Noun );
}
};
}
示例11: ValidationService
public ValidationService(IRequestResponsePairQueryService requestResponsePairQueryService,
IUseCaseQueryService useCaseQueryService,
ICommandHandler<CreateUseCaseValidation> commandHandler)
{
_requestResponsePairQueryService = requestResponsePairQueryService;
_useCaseQueryService = useCaseQueryService;
_commandHandler = commandHandler;
}
示例12: UserController
public UserController(ICommandHandler<CreateBasicUser> createUserCommandHandler, ICommandHandler<AddFriendToUser> addFriendCommandHandler, ICommandHandler<DisableUser> disableUserCommandHandler, ICommandHandler<AddWishListItem> addWishListItemCommandHandler, ICommandHandler<EnableUser> enableUserCommandHandler)
{
_createUserCommandHandler = createUserCommandHandler;
_addFriendCommandHandler = addFriendCommandHandler;
_disableUserCommandHandler = disableUserCommandHandler;
_addWishListItemCommandHandler = addWishListItemCommandHandler;
_enableUserCommandHandler = enableUserCommandHandler;
}
示例13: OrganizationController
public OrganizationController(ICommandHandler<CreateOrganization, Organization> createOrganization,
IQueryHandler<GetOrganization, Organization> getOrganization,
IQueryHandler<ListOrganizations, IEnumerable<Organization>> listOrganizations)
{
_createOrganization = createOrganization;
_getOrganization = getOrganization;
_listOrganizations = listOrganizations;
}
示例14: AccountController
public AccountController(ApplicationUserManager userManager,
ApplicationSignInManager signInManager,
ICommandHandler<RegisterUserCommand> registerUserCommandHandler)
{
UserManager = userManager;
SignInManager = signInManager;
_registerUserCommandHandler = registerUserCommandHandler;
}
示例15: Invoke
public virtual void Invoke(ICommandHandler handler, ICommand command)
{
Ensure.That(handler, "handler").IsNotNull();
Ensure.That(command, "command").IsNotNull();
var container = ContainerFactory.Invoke(handler.ContainerType);
handler.Handler.Invoke(container, new object[] { command });
}