Esempio n. 1
0
        static public void Configure(IServiceCollection serviceCollection)
        {
            //TODO: add interfaces for some of these
            serviceCollection.AddSingleton <SuspendAndResumeService>();
            serviceCollection.AddSingleton <CommandLineActivationHandler>();

            serviceCollection.AddHttpClient(Options.DefaultName, (client) => { client.BaseAddress = new Uri(Secrets.ServerUrl); });

            serviceCollection.AddSingleton <HttpClient>((provider) => provider.GetService <IHttpClientFactory>().CreateClient());

            serviceCollection.AddSingleton <ILogger>((_) => LoggingFactory.BuildLogger());

            // Only ever have one player in the application
            serviceCollection.AddSingleton <PlayerViewModel>();

            serviceCollection.AddSingleton <ServerCaller>();

            //serviceCollection.AddSingleton((provider) => new ServerCaller(provider.GetService<IHttpClientFactory>().CreateClient()));

            string dbPath = FileHelper.GetLibraryDbPath();

            serviceCollection.AddSingleton <SqliteConnection>((_) => SQLiteHelpers.CreateFileDb(dbPath));

            serviceCollection.AddSingleton <Library>();

            //serviceCollection.AddSingleton((provider) => new Library(Environment.MachineName, SQLiteHelpers.CreateFileDb(dbPath),
            //    provider.GetService<ServerCaller>(), provider.GetService<ILogger>()));

            //serviceCollection.AddScoped<ICommonServices, CommonServices>();
            //serviceCollection.AddTransient<LoginViewModel>();

            _rootServiceProvider = serviceCollection.BuildServiceProvider();
        }
Esempio n. 2
0
 static void Main()
 {
     Logger = LoggingFactory.BuildLogger();
     try
     {
         using (var service = new Program())
         {
             if (Environment.UserInteractive)
             {
                 service.OnStart(null);
                 Console.WriteLine("Press any key to stop program");
                 Console.Read();
                 service.OnStop();
             }
             else
             {
                 Run(service);
             }
         }
     }
     catch (Exception exception)
     {
         Logger.ErrorException("Failed to start ", exception);
     }
     finally
     {
         //TODO: hack to make nlog work with mono. remove when nlog is updated
         LogManager.Configuration = null;
     }
 }
Esempio n. 3
0
 public override bool Execute()
 {
     using (var container = new CompositionContainer(catalog))
     {
         var moduleDefinition = ModuleDefinition.ReadModule(AssemblyPath);
         var buildLogger      = LoggingFactory.BuildLogger();
         foreach (var typeDefinition in moduleDefinition.Types)
         {
             buildLogger.Info(typeDefinition);
         }
         var jObject = new JObject();
     }
     return(true);
 }
Esempio n. 4
0
 protected override void OnStart(string[] args)
 {
     LoggingFactory.BuildLogger();
     BuildBus();
 }