Exemple #1
0
        public void GetCommandsFromAssembly()
        {
            ConsoleAutoConfig config = null;

            ConsoleAuto
            .Config(null)
            .LoadCommands(typeof(MyCommandClass).Assembly)
            .Configure(x =>
            {
                config = x;
            });

            TestConfig(config);
        }
Exemple #2
0
        public void GetCommandsFromAnnotations()
        {
            ConsoleAutoConfig config = null;

            ConsoleAuto
            .Config(null)
            .LoadFromClass(typeof(MyCommandClass))
            .Configure(x =>
            {
                config = x;
            });

            TestConfig(config);
        }
Exemple #3
0
        private void TestConfig(ConsoleAutoConfig config)
        {
            Assert.Equal(3, config.AvailableCommands.Count);

            Assert.True(config.AvailableCommands.Any(x => x.Name == "CommandOne"));
            Assert.True(config.AvailableCommands.Any(x => x.Name == "CommandEmpty"));
            Assert.True(config.AvailableCommands.Any(x => x.Name == "Console Named"));

            var commandOne = config.AvailableCommands.FirstOrDefault(x => x.Name == "CommandOne");

            Assert.True(commandOne.DefaultArgs.Count == 3);
            Assert.True(commandOne.DefaultArgs.ContainsKey("test"));
            Assert.True(commandOne.DefaultArgs.ContainsKey("test2"));
            Assert.True(commandOne.DefaultArgs.ContainsKey("text"));
            Assert.Equal(commandOne.DefaultArgs["test"], 23);
            Assert.Equal(commandOne.DefaultArgs["test2"], true);
        }
Exemple #4
0
        public ConsoleAuto(string[] args = null, IServiceCollection serviceBuilder = null)
        {
            config    = new ConsoleAutoConfig();
            this.args = new List <string>(args ?? new string[] { });

            this.serviceBuilder = serviceBuilder ?? new ServiceCollection();

            this.Register <ReflectionService>();
            this.Register <ConsoleService>();

            this.sp = this.serviceBuilder?.BuildServiceProvider() as IServiceProvider;

            this.reflectionService = this.sp.GetService(typeof(ReflectionService)) as ReflectionService;
            this.consoleService    = this.sp.GetService(typeof(ConsoleService)) as ConsoleService;


            deserializer = new Deserializer();
        }
Exemple #5
0
 public InfoCommands(ConsoleService consoleService, ConsoleAutoConfig config)
 {
     this.consoleService = consoleService;
     this.config         = config;
 }