コード例 #1
0
 public CosmeticsEngine(IDataStore dataStore, IConsoleRenderer consoleRenderer,
                        ICommandsFactory commandsFactory)
 {
     this.dataStore       = dataStore;
     this.commandsFactory = commandsFactory;
     this.consoleRenderer = consoleRenderer;
 }
コード例 #2
0
        public InboundMessagesHandler(MqttClientWrapper mqttClient, ICommandBus commandBus,
                                      ICommandsFactory commandsFactory, IOutboundEventBus outboundEventBus)
        {
            mqttClient.OnMqttMessageReceived += (_, args) =>
            {
                try
                {
                    var decodedMessage = DecodeMqttMessage(args);
                    var command        = commandsFactory.Create(decodedMessage.Name, decodedMessage.Payload);
                    var errors         = command.Validate();
                    if (errors.Length > 0)
                    {
                        outboundEventBus.Send(new CommandResultEvent(command.CorrelationId, StatusCode.ValidationError,
                                                                     command.GetType().Name, errors.SerializeToString()));
                        return;
                    }

                    commandBus.Send(command);
                }
                catch (Exception e)
                {
                    outboundEventBus.Send(new ErrorEvent(
                                              $"Exception during handling inbound message: {e.Message}", ErrorLevel.Warning));
                }
            };
        }
コード例 #3
0
        /// <summary>
        /// Constructor for commands dispatcher
        /// </summary>
        /// <param name="commandsFactory">Commands factory</param>
        public CommandsDispatcher(ICommandsFactory commandsFactory)
        {
            if (commandsFactory == null)
            {
                throw new ArgumentNullException(nameof(commandsFactory));
            }

            _commandsFactory = commandsFactory;
        }
コード例 #4
0
        public CommandProcessor(ICommandsFactory factory)
        {
            if (factory == null)
            {
                throw new ArgumentNullException("Null factory value is passed for command processor parameter");
            }

            this.factory = factory;
        }
 public ActionsController(IDataState data, INotifier notifier, INumberGenerator numberGenerator, IScoreboard scoreboard, ICommandsFactory commandsFactory, IActionsReader reader)
 {
     this.Data = data;
     this.ActionsReader = reader;
     this.Notifier = notifier;
     this.Scoreboard = scoreboard;
     this.CommandsFactory = commandsFactory;
     this.NumberGenerator = numberGenerator;
 }
コード例 #6
0
ファイル: Program.cs プロジェクト: RadSt/CQS-Sample
        private static void Main(string[] args)
        {
            // Getting the factories
            IQueryFactory    queryFactory    = Container.Current.Resolve <IQueryFactory>();
            ICommandsFactory commandsFactory = Container.Current.Resolve <ICommandsFactory>();


            // Executing commands
            Console.WriteLine("Crating new user...");

            CreateUserCommand createUserCommand = new CreateUserCommand(
                Guid.NewGuid().ToString().ToUpperInvariant().Replace("-", "").Substring(0, 6),
                Guid.NewGuid().ToString().ToUpperInvariant().Replace("-", "").Substring(0, 6),
                Guid.NewGuid().ToString().ToUpperInvariant().Replace("-", "").Substring(0, 6) + "@email.com");

            commandsFactory.ExecuteQuery(createUserCommand);

            Console.WriteLine("User created with Id = {0}", createUserCommand.Id);
            Console.WriteLine();


            // Executing queries
            IEnumerable <User> activeUsers = queryFactory
                                             .ResolveQuery <IActiveUsersQuery>()
                                             .Execute();

            Console.WriteLine("Active users: ");
            foreach (User t in activeUsers)
            {
                Console.WriteLine("{0} {1} {2} {3}", t.Id, t.LastName, t.FirstName, t.Email);
            }
            Console.WriteLine();


            IEnumerable <User> inactiveUsers = queryFactory
                                               .ResolveQuery <IInactiveUsersQuery>()
                                               .Execute();

            Console.WriteLine("Inactive users: ");
            foreach (User t in inactiveUsers)
            {
                Console.WriteLine("{0} {1} {2} {3}", t.Id, t.LastName, t.FirstName, t.Email);
            }
            Console.WriteLine();


            User user = queryFactory
                        .ResolveQuery <IUserByEmailQuery>()
                        .Execute("*****@*****.**");

            Console.WriteLine("User by e-mail \"[email protected]\":");
            Console.WriteLine("{0} {1} {2} {3}", user.Id, user.LastName, user.FirstName, user.Email);

            Console.Read();
        }
コード例 #7
0
ファイル: DefaultRouter.cs プロジェクト: SpireX64/Navix
        public DefaultRouter(IScreenRegistry registry, INavigationManager navigationManager, ICommandsFactory commandsFactory)
        {
            _registry = registry
                        ?? throw new ArgumentNullException(nameof(navigationManager));

            _navigationManager = navigationManager
                                 ?? throw new ArgumentNullException(nameof(navigationManager));

            _commandsFactory = commandsFactory
                               ?? throw new ArgumentNullException(nameof(commandsFactory));
        }
コード例 #8
0
 public Engine(ICommandsFactory commandsFactory,
               IPrintReports printReports,
               IMainMenu mainMenu,
               ICommandParser parser,
               IReader reader)
 {
     this.commandsFactory = commandsFactory ?? throw new ArgumentException(string.Format(Consts.NULL_OBJECT, nameof(commandsFactory)));
     this.printReports    = printReports ?? throw new ArgumentException(string.Format(Consts.NULL_OBJECT, nameof(printReports)));
     this.mainMenu        = mainMenu ?? throw new ArgumentException(string.Format(Consts.NULL_OBJECT, nameof(mainMenu)));
     this.reader          = reader;
     this.parser          = parser;
 }
コード例 #9
0
        // !!!! Before reading this method, see:
        // - What's inside the ICommandFactory
        // - How ICommandFactory is used inside the Engine
        private void RegisterDynamicFactory(ContainerBuilder builder)
        {
            // ExpandoObject is a class in C# to which you can add whatever methods or properties you want
            dynamic factoryProxy = new ExpandoObject();

            // This is the body of the method I assign below. It uses the Autofac container to get a command by it's name.
            // Those commands are bound in the RegisterDynamicCommands method.
            Func <string, ICommand> methodBody = (commandName => this.Container.ResolveNamed <ICommand>(commandName.ToLower()));

            // I create a "method" called GetCommand, using the delegate above
            factoryProxy.GetCommand = methodBody;

            // Using the impromptu-interface library, I convert this dynamic object to the interface ICommandFactory.
            ICommandsFactory factoryShell = Impromptu.ActLike <ICommandsFactory>(factoryProxy);

            // Then i say - whenever you want an implementation of ICommandsFactory (like in the Engine)
            // Use the object I created dynamically above
            builder.RegisterInstance(factoryShell).As <ICommandsFactory>();

            // Magic!
        }
コード例 #10
0
ファイル: MapController.cs プロジェクト: DarkFIxED/topocat
 public MapController(ICommandsFactory commandsFactory, IQueriesFactory queriesFactory)
 {
     _commandsFactory = commandsFactory;
     _queriesFactory  = queriesFactory;
 }
コード例 #11
0
 public UserUpdateResponse(ICommandsFactory commandsFactory, ILogger <UserUpdateResponse> logger)
 {
     _commandsFactory = commandsFactory;
     _logger          = logger;
 }
コード例 #12
0
 public HelpCommand(ICommandsFactory commandFactory)
 {
     _commandFactory = commandFactory;
 }
コード例 #13
0
 public UserCreatedEventConsumer(IConnection connection, ICommandsFactory commands, ILog logger)
 {
     this.connection = connection;
     this.commands   = commands;
     this.logger     = logger;
 }
コード例 #14
0
 public CreateArmyController(ICommandsFactory commands, ILog log)
 {
     this.commands = commands;
     this.log      = log;
 }
コード例 #15
0
 public FurnitureEngine(IRenderer consoleRenderer, ICommandsFactory factory)
 {
     this.renderer = consoleRenderer;
     this.factory  = factory;
 }
コード例 #16
0
 private CommandProcessor(ICommandsFactory factory)
 {
     this.factory = factory ?? new CommandsFactory(null, null);
 }
コード例 #17
0
 public CommandProcessor(ICommandsFactory commandsFactory)
 {
     this.commandsFactory = commandsFactory;
 }
コード例 #18
0
 public PasswordRestorationController(ICommandsFactory commandsFactory)
 {
     _commandsFactory = commandsFactory;
 }
コード例 #19
0
 public CommandProcessor(ICommandsFactory factory)
 {
     Guard.WhenArgument(factory, "factory").IsNull().Throw();
     this.commandFactory = factory;
 }
コード例 #20
0
 public AsyncSignUpService(IQueuesManager queuesManager, ICommandsFactory commandsFactory)
 {
     _queuesManager   = queuesManager;
     _commandsFactory = commandsFactory;
 }
コード例 #21
0
ファイル: NavixConfig.cs プロジェクト: SpireX64/Navix
 public virtual IRouter GetRouter(IScreenRegistry registry, INavigationManager navigationManager, ICommandsFactory commandsFactory)
 {
     return(new DefaultRouter(registry, navigationManager, commandsFactory));
 }