예제 #1
0
        static void Main(string[] args)
        {
            var iocBootstrap = new IocBootstrap();

            using (var container = iocBootstrap.Install())
            {
                using (var lifetimeScope = container.BeginLifetimeScope())
                {
                    var appSettings = lifetimeScope.Resolve <IAppSettings>();

                    if (args.Any())
                    {
                        var command = string.Join(" ", args);
                        var result  = TrySendCommandAsync(appSettings.BaseAddress, command).Result;
                        if (result)
                        {
                            return;
                        }
                    }

                    Log.Info("Starting new instance...");

                    var player = lifetimeScope.Resolve <IPlayer>();
                    player.Run(appSettings);

                    player.SendCommand(new LoginCommand {
                        Username = appSettings.Username, Password = appSettings.Password
                    });

                    var services = (ServiceProvider)ServicesFactory.Create();
                    var options  = new StartOptions(appSettings.BaseAddress);

                    services.AddInstance <ILifetimeScope>(lifetimeScope);

                    var starter = services.GetService <IHostingStarter>();

                    using (starter.Start(options))
                    {
                        if (args.Any())
                        {
                            var command = string.Join(" ", args);
                            TrySendCommandAsync(appSettings.BaseAddress, command).Wait();
                        }

                        Log.Info("Waiting for input to quit");
                        Console.ReadKey(true);
                    }
                }
            }
        }
예제 #2
0
        static void Main(string[] args)
        {
            var iocBootstrap = new IocBootstrap();

            using (var container = iocBootstrap.Install())
            {
                using (var lifetimeScope = container.BeginLifetimeScope())
                {
                    var appSettings = lifetimeScope.Resolve<IAppSettings>();

                    if (args.Any())
                    {
                        var command = string.Join(" ", args);
                        var result = TrySendCommandAsync(appSettings.BaseAddress, command).Result;
                        if (result)
                        {
                            return;
                        }
                    }

                    Log.Info("Starting new instance...");

                    var player = lifetimeScope.Resolve<IPlayer>();
                    player.Run(appSettings);

                    player.SendCommand(new LoginCommand { Username = appSettings.Username, Password = appSettings.Password });

                    var services = (ServiceProvider)ServicesFactory.Create();
                    var options = new StartOptions(appSettings.BaseAddress);

                    services.AddInstance<ILifetimeScope>(lifetimeScope);

                    var starter = services.GetService<IHostingStarter>();

                    using (starter.Start(options))
                    {
                        if (args.Any())
                        {
                            var command = string.Join(" ", args);
                            TrySendCommandAsync(appSettings.BaseAddress, command).Wait();
                        }

                        Log.Info("Waiting for input to quit");
                        Console.ReadKey(true);
                    }
                }
            }
        }