示例#1
0
 public HandleAnswer(CommandContext context, BooleanAnswerHandler handler)
 {
     _type    = AnswerType.Boolean;
     _options = context.HttpContext.RequestServices.GetRequiredService <IOptions <BeavisCliOptions> >().Value;
     _booleanAnswerHandler = handler;
     _context = context;
 }
示例#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);
        }
示例#3
0
 public RequestHandler(ILogger <RequestHandler> logger, IOptions <BeavisCliOptions> options)
 {
     _logger  = logger;
     _options = options.Value;
 }
示例#4
0
 public CommandExecutionEnvironment(IOptions <BeavisCliOptions> options)
 {
     _options = options.Value;
 }
示例#5
0
 public BeavisCliMiddleware(RequestDelegate next, ILogger <BeavisCliMiddleware> logger, IOptions <BeavisCliOptions> options)
 {
     _next    = next;
     _logger  = logger;
     _options = options.Value;
 }
示例#6
0
 public TerminalInitializer(IOptions <BeavisCliOptions> options)
 {
     _options = options.Value;
 }
示例#7
0
 public CommandProvider(IOptions <BeavisCliOptions> options)
 {
     _options = options.Value;
 }