Exemple #1
0
        public static IServiceCollection AddLmptCoreService(this IServiceCollection serviceCollection,
                                                            DirectoryInfo appDataFolder = null)
        {
            try
            {
                serviceCollection
                .AddSingleton <ConfigurationProvider>()
                .AddSingleton(s =>
                {
                    if (appDataFolder != null)
                    {
                        return(CoreSettings.GetCoreSettings(appDataFolder));
                    }

                    var root = s.GetService <ConfigurationProvider>().RootDirectory;
                    return(CoreSettings.GetCoreSettings(root));
                })
                .AddSingleton <HttpCache>()

                .AddScoped <Importer>()
                .AddTransient <ThrottlerLocator>()
                .AddTransient <DataAccess>()
                .AddTransient <BookmarkScanner>()
                .AddSingleton <DbContextFactory>();



                serviceCollection.AddForegroundHttpClient <LiveMeAuthenticator>();
                serviceCollection.AddForegroundHttpClient <LivemeApiProvider>();
                serviceCollection.AddBackgroundHttpClient <LivemeApiProviderBackground>();
                return(serviceCollection);
            }
            catch (Exception e)
            {
                Console.WriteLine("Failed to set up dependencies " + e);
                throw;
            }
        }