public LocalStorageService(IOptions <LocalStorageOptions> options) { _options = options.Value; if (!Directory.Exists(_options.RootDir)) { Directory.CreateDirectory(_options.RootDir); } }
public static IServiceCollection AddLocalStorage(this IServiceCollection services, Action <IDbConnectionBuilder> action) { var options = new LocalStorageOptions(); action(new DbConnectionBuilder(options)); services.TryAddSingleton(options); services.TryAddSingleton <IDbConnectionFactory, DbConnectionFactory>(); return(services); }
public static ILocalStorageService AddBlazoredLocalStorage(this TestContextBase context, Action <LocalStorageOptions> configure) { if (context is null) { throw new ArgumentNullException(nameof(context)); } var localStorageOptions = new LocalStorageOptions(); configure?.Invoke(localStorageOptions); localStorageOptions.JsonSerializerOptions.Converters.Add(new TimespanJsonConverter()); var localStorageService = new LocalStorageService(new InMemoryStorageProvider(), new SystemTextJsonSerializer(localStorageOptions)); context.Services.AddSingleton <ILocalStorageService>(localStorageService); return(localStorageService); }
public DefaultStoreManager(LocalStorageOptions options, IEntityType entityType, ISyncLocalStorageService localStorage) { if (options.Serializer == "xml") { _serializer = new XMLSerializer <T>(entityType, entityType.FindPrimaryKey().GetPrincipalKeyValueFactory <T>()); } else if (options.Serializer == "bson") { _serializer = new BSONSerializer <T>(entityType, entityType.FindPrimaryKey().GetPrincipalKeyValueFactory <T>()); } else if (options.Serializer == "csv") { _serializer = new CSVSerializer <T>(entityType, entityType.FindPrimaryKey().GetPrincipalKeyValueFactory <T>()); } else { _serializer = new JSONSerializer <T>(entityType, entityType.FindPrimaryKey().GetPrincipalKeyValueFactory <T>()); } string fmgr = options.FileManager ?? "default"; string filetype = options.Serializer ?? "json"; if (fmgr.Length >= 9 && fmgr.Substring(0, 9) == "encrypted") { string password = ""; if (fmgr.Length > 9) { password = fmgr.Substring(10); } _fileManager = new EncryptedLocalStorageFileManager(entityType, filetype, password, options.DatabaseName, localStorage); } else { _fileManager = new LocalStorageFileManager(entityType, filetype, options.DatabaseName, localStorage); } }
public SystemTextJsonSerializer(LocalStorageOptions localStorageOptions) { _options = localStorageOptions.JsonSerializerOptions; }
public DbConnectionBuilder(LocalStorageOptions options) { this.options = options; }
public LocalStorageService(IHttpContextAccessor _httpContext,IOptionsSnapshot<LocalStorageOptions> options) { httpContext = _httpContext; Options = options.Value; }
private static Func <IInMemoryTable> CreateFactory <TKey>( IEntityType entityType, bool sensitiveLoggingEnabled, LocalStorageOptions options, ISyncLocalStorageService localStorage) => () => new SerializableTable <TKey>(entityType, sensitiveLoggingEnabled, new DefaultStoreManager <TKey>(options, entityType, localStorage));
public SerializableTableFactory(ILoggingOptions loggingOptions, LocalStorageOptions localStorageOptions, ISyncLocalStorageService localStorage) { _sensitiveLoggingEnabled = loggingOptions.IsSensitiveDataLoggingEnabled; _localStorageOptions = localStorageOptions; _localStorage = localStorage; }
public LocalStorageOptionsExtension(IJSRuntime jSRuntime, LocalStorageOptions options) { _jSRuntime = jSRuntime; _options = options; }
public static IServiceCollection AddEntityFrameworkLocalStorageDatabase(this IServiceCollection serviceCollection, IJSRuntime jSRuntime, LocalStorageOptions options) { serviceCollection.AddSingleton <IJSRuntime>(jSRuntime); serviceCollection.AddSingleton(options); //Override ProviderSpecificServices serviceCollection.AddSingleton <IInMemoryStoreCache, SerializableStoreCache>(); serviceCollection.AddSingleton <IInMemoryTableFactory, SerializableTableFactory>(); serviceCollection.AddBlazoredLocalStorage(); serviceCollection.AddEntityFrameworkInMemoryDatabase(); return(serviceCollection); }
public LocalStorageAccess(IOptionsSnapshot <LocalStorageOptions> localStorageOptions) { StorageOptions = localStorageOptions.Value; }