public CosmeticsEngine(IDataStore dataStore, IConsoleRenderer consoleRenderer, ICommandsFactory commandsFactory) { this.dataStore = dataStore; this.commandsFactory = commandsFactory; this.consoleRenderer = consoleRenderer; }
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)); } }; }
/// <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; }
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; }
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(); }
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)); }
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; }
// !!!! 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! }
public MapController(ICommandsFactory commandsFactory, IQueriesFactory queriesFactory) { _commandsFactory = commandsFactory; _queriesFactory = queriesFactory; }
public UserUpdateResponse(ICommandsFactory commandsFactory, ILogger <UserUpdateResponse> logger) { _commandsFactory = commandsFactory; _logger = logger; }
public HelpCommand(ICommandsFactory commandFactory) { _commandFactory = commandFactory; }
public UserCreatedEventConsumer(IConnection connection, ICommandsFactory commands, ILog logger) { this.connection = connection; this.commands = commands; this.logger = logger; }
public CreateArmyController(ICommandsFactory commands, ILog log) { this.commands = commands; this.log = log; }
public FurnitureEngine(IRenderer consoleRenderer, ICommandsFactory factory) { this.renderer = consoleRenderer; this.factory = factory; }
private CommandProcessor(ICommandsFactory factory) { this.factory = factory ?? new CommandsFactory(null, null); }
public CommandProcessor(ICommandsFactory commandsFactory) { this.commandsFactory = commandsFactory; }
public PasswordRestorationController(ICommandsFactory commandsFactory) { _commandsFactory = commandsFactory; }
public CommandProcessor(ICommandsFactory factory) { Guard.WhenArgument(factory, "factory").IsNull().Throw(); this.commandFactory = factory; }
public AsyncSignUpService(IQueuesManager queuesManager, ICommandsFactory commandsFactory) { _queuesManager = queuesManager; _commandsFactory = commandsFactory; }
public virtual IRouter GetRouter(IScreenRegistry registry, INavigationManager navigationManager, ICommandsFactory commandsFactory) { return(new DefaultRouter(registry, navigationManager, commandsFactory)); }