当前位置: 首页>>代码示例>>C#>>正文


C# ICommandHandler类代码示例

本文整理汇总了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
                 };
             }
         }
     }
 }
开发者ID:adwardliu,项目名称:Orchard2,代码行数:26,代码来源:DefaultCommandManager.cs

示例2: CommandController

 public CommandController(
     ICommandHandler<CreateProductCommand> createProductCommandHandler,
     ICommandHandler<CreateProductVersionCommand> createProductVersionCommandHandler)
 {
     this.createProductCommandHandler = createProductCommandHandler;
     this.createProductVersionCommandHandler = createProductVersionCommandHandler;
 }
开发者ID:hangy,项目名称:OopsyPlan,代码行数:7,代码来源:CommandController.cs

示例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();
 }
开发者ID:ikvm,项目名称:webmatrix,代码行数:27,代码来源:DocumentWindow.cs

示例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);
            }
        }
开发者ID:fvilers,项目名称:Darjeel,代码行数:26,代码来源:CommandHandlerRegistry.cs

示例5: CommandExampleController

 public CommandExampleController(
     ICommandHandler<CreateOrderCommand> createOrderhandler,
     ICommandHandler<ShipOrderCommand> shipOrderhandler)
 {
     this.createOrderhandler = createOrderhandler;
     this.shipOrderhandler = shipOrderhandler;
 }
开发者ID:brentarias,项目名称:solidservices,代码行数:7,代码来源:CommandExampleController.cs

示例6: ServiceConsumer

 public ServiceConsumer(
     ICommandHandler<AddDelegateCommand> addHandler, 
     ICommandHandler<UpdateDelegateCommand> updateHandler)
 {
     this.addHandler = addHandler;
     this.updateHandler = updateHandler;
 }
开发者ID:trailmax,项目名称:CQRS.Talk,代码行数:7,代码来源:3.Consumer.cs

示例7: OrderApiService

 public OrderApiService(
     ICommandHandler<MakeOrderCommand> commmHandler,
     IOrderRepository repository)
 {
     _commmHandler = commmHandler;
     _repository = repository;
 }
开发者ID:aburok,项目名称:NorthwindStore,代码行数:7,代码来源:OrderApiService.cs

示例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
                        };
                    }
                }
            }
        }
开发者ID:jchenga,项目名称:Orchard2,代码行数:34,代码来源:DefaultCommandManager.cs

示例9: MainCommandHandlerChain

		public MainCommandHandlerChain(
			IConsole console,
			ICommandHandler[] commandHandlers)
		{
			_console = console;
			_commandHandlers = commandHandlers;
		}
开发者ID:neoaisac,项目名称:Codurance.CLI,代码行数:7,代码来源:MainCommandHandlerChain.cs

示例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 );
                }
            };
        }
开发者ID:upta,项目名称:LeagueTag,代码行数:28,代码来源:ShellViewModel.cs

示例11: ValidationService

 public ValidationService(IRequestResponsePairQueryService requestResponsePairQueryService,
                             IUseCaseQueryService useCaseQueryService,
                             ICommandHandler<CreateUseCaseValidation> commandHandler)
 {
     _requestResponsePairQueryService = requestResponsePairQueryService;
     _useCaseQueryService = useCaseQueryService;
     _commandHandler = commandHandler;
 }
开发者ID:ryanande,项目名称:ApiProxy,代码行数:8,代码来源:ValidationService.cs

示例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;
 }
开发者ID:rmacdonaldsmith,项目名称:EventSourcedUserService,代码行数:8,代码来源:UserController.cs

示例13: OrganizationController

 public OrganizationController(ICommandHandler<CreateOrganization, Organization> createOrganization,
     IQueryHandler<GetOrganization, Organization> getOrganization,
     IQueryHandler<ListOrganizations, IEnumerable<Organization>> listOrganizations)
 {
     _createOrganization = createOrganization;
     _getOrganization = getOrganization;
     _listOrganizations = listOrganizations;
 }
开发者ID:modulexcite,项目名称:Fooidity,代码行数:8,代码来源:OrganizationController.cs

示例14: AccountController

 public AccountController(ApplicationUserManager userManager,
     ApplicationSignInManager signInManager,
     ICommandHandler<RegisterUserCommand> registerUserCommandHandler)
 {
     UserManager = userManager;
     SignInManager = signInManager;
     _registerUserCommandHandler = registerUserCommandHandler;
 }
开发者ID:vgichar,项目名称:shah,代码行数:8,代码来源:AccountController.cs

示例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 });
        }
开发者ID:girish66,项目名称:LiteCQRS,代码行数:8,代码来源:CommandHandlerInvoker.cs


注:本文中的ICommandHandler类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。