public static IChecksummedPersistentStorageService GetPersistentStorageService(this HostWorkspaceServices services, StorageDatabase database)
        {
            var configuration = services.GetRequiredService <IPersistentStorageConfiguration>();

            return(database switch
            {
#if !DOTNET_BUILD_FROM_SOURCE
                StorageDatabase.SQLite
                => services.GetService <SQLitePersistentStorageService>() ??
                NoOpPersistentStorageService.GetOrThrow(configuration),
#endif
                StorageDatabase.CloudCache
                => services.GetService <ICloudCacheStorageService>() ??
                NoOpPersistentStorageService.GetOrThrow(configuration),
                _ => NoOpPersistentStorageService.GetOrThrow(configuration),
            });
Example #2
0
        public static IChecksummedPersistentStorageService GetPersistentStorageService(this HostWorkspaceServices services, StorageDatabase database)
        {
            var configuration = services.GetRequiredService <IPersistentStorageConfiguration>();

            switch (database)
            {
            case StorageDatabase.SQLite:
                return(services.GetService <ISQLiteStorageServiceFactory>()?.Create(configuration) ??
                       NoOpPersistentStorageService.GetOrThrow(configuration));

            case StorageDatabase.CloudCache:
                return(services.GetService <ICloudCacheStorageServiceFactory>()?.Create(configuration) ??
                       NoOpPersistentStorageService.GetOrThrow(configuration));

            default:
                return(NoOpPersistentStorageService.GetOrThrow(configuration));
            }
        }
        public IWorkspaceService CreateService(HostWorkspaceServices workspaceServices)
        {
            var options         = workspaceServices.Workspace.Options;
            var locationService = workspaceServices.GetService <IPersistentStorageLocationService>();

            if (locationService != null)
            {
                var database = GetDatabase(workspaceServices);
                switch (database)
                {
                case StorageDatabase.SQLite:
                    return(new SQLitePersistentStorageService(options, _connectionPoolService, locationService, _asyncListener));

                case StorageDatabase.CloudCache:
                    var factory = workspaceServices.GetService <ICloudCacheStorageServiceFactory>();

                    return(factory == null
                            ? NoOpPersistentStorageService.GetOrThrow(options)
                            : factory.Create(locationService));
                }
            }

            return(NoOpPersistentStorageService.GetOrThrow(options));
        }