Exemple #1
0
 public HandleAnswer(CommandContext context, BooleanAnswerHandler handler)
 {
     _type    = AnswerType.Boolean;
     _options = context.HttpContext.RequestServices.GetRequiredService <IOptions <BeavisCliOptions> >().Value;
     _booleanAnswerHandler = handler;
     _context = context;
 }
Exemple #2
0
        public static IServiceCollection AddBeavisCli(this IServiceCollection services, Action <BeavisCliOptions> setup = null)
        {
            // register options
            var options = new BeavisCliOptions();

            if (setup == null)
            {
                setup = x => { };
            }

            setup(options);
            services.Configure(setup);

            // register required services
            services.Add(options.CommandProvider);
            services.Add(options.RequestHandler);
            services.Add(options.JobPoolService);
            services.Add(options.UnauthorizedHandler);
            services.Add(options.TerminalInitializer);
            services.Add(options.FileStorage);
            services.Add(options.CommandExecutionEnvironment);

            // register built-in commands
            foreach (CommandBehaviour command in options.BuiltInCommandBehaviours.Values)
            {
                if (command.IsEnabled)
                {
                    services.Add(ServiceDescriptor.Singleton(typeof(ICommand), command.ImplementationType));
                }
            }

            ServicesRegistered = true;

            return(services);
        }
Exemple #3
0
 public RequestHandler(ILogger <RequestHandler> logger, IOptions <BeavisCliOptions> options)
 {
     _logger  = logger;
     _options = options.Value;
 }
Exemple #4
0
 public CommandExecutionEnvironment(IOptions <BeavisCliOptions> options)
 {
     _options = options.Value;
 }
 public BeavisCliMiddleware(RequestDelegate next, ILogger <BeavisCliMiddleware> logger, IOptions <BeavisCliOptions> options)
 {
     _next    = next;
     _logger  = logger;
     _options = options.Value;
 }
 public TerminalInitializer(IOptions <BeavisCliOptions> options)
 {
     _options = options.Value;
 }
Exemple #7
0
 public CommandProvider(IOptions <BeavisCliOptions> options)
 {
     _options = options.Value;
 }