Пример #1
0
        /// <summary>
        ///     Perform initial setup of commands library by finding all commands handlers in <paramref name="assemblies" />
        ///     and registering them in <paramref name="container" /> with specified <paramref name="lifestyle" />.
        /// </summary>
        /// <param name="container">Container that will be used for registration. If null the inner container will be created.</param>
        /// <param name="lifestyle">Default lifestyle for command handlers. If null the transient lifestyle will be used.</param>
        /// <param name="verifyAllCommandsHasHandlers">
        ///     If true will throws <see cref="CommandHandlerNotFoundException" /> for any
        ///     command found without appropriate command handler.
        /// </param>
        /// <param name="assemblies">
        ///     A list of assemblies to scan for <see cref="ICommandHandler{TCommand,TResult}" />
        ///     implementations. If null or empty the calling assembly will be used.
        /// </param>
        public static void Setup(Container container = null,
                                 Lifestyle lifestyle = null,
                                 bool verifyAllCommandsHasHandlers = true,
                                 params Assembly[] assemblies)
        {
            Container = container ?? new Container {
                Options = { AllowOverridingRegistrations = true }
            };
            defaultLifestyle = lifestyle ?? Lifestyle.Transient;

            if (assemblies == null || assemblies.Length == 0)
            {
                assemblies = new[] { Assembly.GetCallingAssembly() }
            }
            ;

            var handler_factory = new SimpleInjectorCommandHandlerFactory(Container);

            Container.RegisterInstance(handler_factory);

            CommandsProcessor = new CommandsProcessor(handler_factory);
            Container.RegisterInstance(CommandsProcessor);

            RegisterAllCommandHandlers(Container, lifestyle, verifyAllCommandsHasHandlers, assemblies);
        }
Пример #2
0
 public ScheduledTask
 (
     ICommandsProcessor processor
 )
 {
     _processor = processor ?? throw new ArgumentNullException(nameof(processor));
 }
Пример #3
0
 public SchedulerService(
     ICommandsProcessor processor,
     IScheduleRepository scheduleRepository
     )
 {
     _processor          = processor ?? throw new ArgumentNullException(nameof(processor));
     _scheduleRepository = scheduleRepository ?? throw new ArgumentNullException(nameof(scheduleRepository));
 }
Пример #4
0
 public CheckRegistrator
 (
     ICommandsProcessor checksProcessor,
     ISchedulerService scheduler
 )
 {
     _checksProcessor = checksProcessor ?? throw new ArgumentNullException(nameof(checksProcessor));
     _scheduler       = scheduler ?? throw new ArgumentNullException(nameof(scheduler));
 }
Пример #5
0
 public MonitorController
 (
     ICommandsProcessor commandsProcessor,
     IMediator mediator
 )
 {
     _commandsProcessor = commandsProcessor ?? throw new ArgumentNullException(nameof(commandsProcessor));
     _mediator          = mediator ?? throw new ArgumentNullException(nameof(mediator));
 }
Пример #6
0
        // Constructors
        public Engine(IReader reader, IWriter writer, ICommandsProcessor commandsProcessor)
        {
            this.reader            = reader;
            this.writer            = writer;
            this.commandsProcessor = commandsProcessor;

            this.Seasons  = new List <ISeason>();
            this.Students = new List <IStudent>();
            this.Trainers = new List <ITrainer>();
        }
Пример #7
0
 public static IEnumerable <Type> GetAllAsyncDecoratorsGenericTypes <TCommand> (this ICommandsProcessor commands)
     where TCommand : IAsyncCommand
 {
     return(commands.GetAllAsyncDecoratorsTypes <TCommand> ().Select(x => x.GetGenericTypeDefinition()));
 }
Пример #8
0
 public static IEnumerable <Type> GetAllDecoratorsTypes <TCommand> (this ICommandsProcessor commands)
     where TCommand : ICommand
 {
     return(commands.GetAllDecorators <TCommand> ().Select(x => x.GetType()));
 }
Пример #9
0
 public BooksController(ICommandsProcessor commandProcessor, IQueriesProcessor queriesProcessor)
 {
     _commandProcessor = commandProcessor;
     _queriesProcessor = queriesProcessor;
 }