Exemplo n.º 1
0
        private static TestLocal InitializeCommander(ICommandRegistrationContainer registrations, Action <IConsoleCommand> assert)
        {
            var memoryRx      = MemoryRx.Create();
            var loggerFactory = new LoggerFactory(memoryRx);

            var builder = new ContainerBuilder();

            builder
            .RegisterInstance(loggerFactory)
            .As <ILoggerFactory>();

            builder
            .RegisterInstance(assert);

            builder
            .RegisterModule(new CommanderModule(registrations));


            var container = builder.Build();
            var scope     = container.BeginLifetimeScope();

            return(new TestLocal(container, scope)
            {
                MemoryRx = memoryRx,
                Executor = scope.Resolve <ICommandLineExecutor>(),
                Assert = assert
            });
        }
Exemplo n.º 2
0
 public CommandParameterMapper(
     [NotNull] ILoggerFactory loggerFactory,
     [NotNull] ICommandRegistrationContainer registrations,
     [NotNull] ITypeConverter converter)
 {
     _logger        = loggerFactory.CreateLogger(nameof(CommandParameterMapper));
     _registrations = registrations ?? throw new ArgumentNullException(nameof(registrations));
     _converter     = converter ?? throw new ArgumentNullException(nameof(converter));
 }
Exemplo n.º 3
0
 public static ICommandRegistrationContainer Register <T>(this ICommandRegistrationContainer commands)
 {
     return(commands.Register(CommandRegistration.Create <T>()));
 }
Exemplo n.º 4
0
 public CommanderModule([NotNull] ICommandRegistrationContainer registrations)
 {
     _registrations = registrations ?? throw new ArgumentNullException(nameof(registrations));
 }
Exemplo n.º 5
0
        public static ICommandLineExecutor Create([NotNull] ILoggerFactory loggerFactory, [NotNull] ICommandRegistrationContainer commands)
        {
            if (loggerFactory == null)
            {
                throw new ArgumentNullException(nameof(loggerFactory));
            }
            if (commands == null)
            {
                throw new ArgumentNullException(nameof(commands));
            }

            var builder = new ContainerBuilder();

            builder
            .RegisterInstance(loggerFactory)
            .As <ILoggerFactory>();

            builder
            .RegisterModule(new CommanderModule(commands));

            using (var container = builder.Build())
                using (var scope = container.BeginLifetimeScope())
                {
                    return(scope.Resolve <ICommandLineExecutor>());
                }
        }
Exemplo n.º 6
0
 public Help(ILoggerFactory loggerFactory, ICommandRegistrationContainer commandRegistrations) : base(loggerFactory)
 {
     _commandRegistrations = commandRegistrations;
 }