• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# ICommandHandler类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中ICommandHandler的典型用法代码示例。如果您正苦于以下问题:C# ICommandHandler类的具体用法?C# ICommandHandler怎么用?C# ICommandHandler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ICommandHandler类属于命名空间,在下文中一共展示了ICommandHandler类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


示例16: GenericCommand

 // ----------------------------------------------------------------------
 public GenericCommand( ICommandHandler commandHandler, object context )
 {
     if ( commandHandler == null )
     {
         throw new ArgumentNullException( "commandHandler" );
     }
     this.commandHandler = commandHandler;
     this.context = context;
 }
开发者ID:jwg4,项目名称:date-difference,代码行数:10,代码来源:GenericCommand.cs


示例17: CommandDispatcher

        public CommandDispatcher(
			ICommandHandler[] handlers,
			Func<IEnumerable<ICommandHandler>> pluginHandlerFactory,
			IEventDispatcher eventDispatcher)
        {
            _handlers = handlers;
            _pluginHandlerFactory = pluginHandlerFactory;
            _eventDispatcher = eventDispatcher;
        }
开发者ID:JamesTryand,项目名称:OpenIDE,代码行数:9,代码来源:CommandDispatcher.cs


示例18: RegisterCommandHandler

        /// <summary>
        /// Registers a handler to be used to process commands.
        /// </summary>
        public void RegisterCommandHandler(ICommandHandler commandHandler)
        {
            if (commandHandler == null) throw new ArgumentNullException("commandHandler");

            if (registeredHandlers.Any(h => h.GetType() == commandHandler.GetType()))
                throw new InvalidOperationException("Handler type " + commandHandler.GetType() + " already registered.");

            registeredHandlers.Add(commandHandler);
        }
开发者ID:dineshkummarc,项目名称:Time-Log,代码行数:12,代码来源:CommandProcessor.cs


示例19:

 public LoginsController
     (
         IRequestHandler<LoginRequest, string> loginHandler,
         ICommandHandler<LogoutRequest> logoutHandler
     )
 {
     this.loginHandler = loginHandler;
     this.logoutHandler = logoutHandler;
 }
开发者ID:Tsonov,项目名称:FMI.WeAzure.Boxing,代码行数:9,代码来源:LoginsController.cs


示例20: Construct_MultipleCommandHandlersForSameCommand_ThrowArgumentException

        public void Construct_MultipleCommandHandlersForSameCommand_ThrowArgumentException()
        {
            // The command bus doesn't currently support multiple command handlers for the same command, make sure that it fails.
            var commandHandlers = new ICommandHandler[] {
                new TestCommandHandler(),
                new TestCommandHandler()
            };

            Assert.Throws<ArgumentException>(() => new CommandExecutor(commandHandlers));
        }
开发者ID:charlesw,项目名称:airion,代码行数:10,代码来源:CommandExecutorTests.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# ICommandManager类代码示例发布时间:2022-05-24
下一篇:
C# ICommandFactory类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap