Exemplo n.º 1
0
        static void Main()
        {
            var root = CommandLineFacilitator
                       .Create(new CustomActivator())
                       .AddCurrentAssembly()
                       .BuildRootCommand();

            while (true)
            {
                Console.WriteLine("try '--help' or 'exit':");
                var c = Console.ReadLine();
                if (c == "exit" || c is null)
                {
                    break;
                }
                root.Invoke(c);

                Console.WriteLine("\nPress to clear");
                Console.ReadKey();
                Console.Clear();
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Register services.
        /// </summary>
        public static string[] Register(string[] args)
        {
            _container = new Container();

            var(startup, restArgs) = StartupArgsFactory.Build(args);
            var life = new MopLifeService(AppState.Life.Token);
            var cmd  = CommandLineFacilitator
                       .Create(new CustomActivator())
                       .AddCurrentAssembly();

            _container.Register(() => startup, Lifestyle.Singleton);
            _container.Register(() => cmd, Lifestyle.Singleton);
            _container.Register(() => life, Lifestyle.Singleton);
            _container.Register <ISettingsLoaderService <AppSettings>, SettingsLoaderService <AppSettings> >(Lifestyle.Singleton);
            _container.Register <ISettingsService, SettingsService>(Lifestyle.Singleton);
            _container.Register <ILogService, LogService>(Lifestyle.Singleton);
            _container.Register <IHostsHandlerService, HostsHandlerService>(Lifestyle.Singleton);
            _container.Register <IParserService, ParserService>(Lifestyle.Singleton);
            _container.Register <IActorService, ActorService>(Lifestyle.Singleton);
            _container.Register <ICommandLineService, CommandLineService>(Lifestyle.Singleton);

            return(restArgs);
        }