예제 #1
0
        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);
        }
예제 #4
0
        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);
            }
        }
예제 #5
0
 public SystemTextJsonSerializer(LocalStorageOptions localStorageOptions)
 {
     _options = localStorageOptions.JsonSerializerOptions;
 }
예제 #6
0
 public DbConnectionBuilder(LocalStorageOptions options)
 {
     this.options = options;
 }
예제 #7
0
 public LocalStorageService(IHttpContextAccessor _httpContext,IOptionsSnapshot<LocalStorageOptions> options)
 {
     httpContext = _httpContext;
     Options = options.Value;
 }
예제 #8
0
 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));
예제 #9
0
 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);
        }
예제 #12
0
 public LocalStorageAccess(IOptionsSnapshot <LocalStorageOptions> localStorageOptions)
 {
     StorageOptions = localStorageOptions.Value;
 }