/// <summary> /// Adds LiteX SQLite Cache manager services /// </summary> /// <param name="services"></param> /// <param name="config">SQLite configuration settings, default: use 'SQLiteConfig' from appsettings.json</param> /// <returns></returns> public static IServiceCollection AddLiteXSQLiteCache(this IServiceCollection services, SQLiteConfig config = null) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected O, but got Unknown //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) if (config == null) { IConfiguration requiredService = ServiceProviderServiceExtensions.GetRequiredService <IConfiguration>((IServiceProvider)ServiceCollectionContainerBuilderExtensions.BuildServiceProvider(services)); IConfigurationSection section = requiredService.GetSection(SQLiteCacheDefaults.SettingsSection); config = ((section != null) ? ConfigurationBinder.Get <SQLiteConfig>(section) : null); if (config == null) { config = new SQLiteConfig { FileName = SQLiteCacheDefaults.FileName, FilePath = SQLiteCacheDefaults.FilePath, OpenMode = 0, CacheMode = 0, EnableLogging = LiteXCacheDefaults.EnableLogging }; } config.FilePath = ((!string.IsNullOrWhiteSpace(config.FilePath)) ? config.FilePath : SQLiteCacheDefaults.FilePath); } return(services.AddLiteXSQLiteCache(delegate(SQLiteConfig option) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) option.FileName = config.FileName; option.FilePath = config.FilePath; option.OpenMode = config.OpenMode; option.CacheMode = config.CacheMode; })); }
/// <summary> /// Ctor /// Initializes a new instance of the <see cref="T:LiteX.Cache.SQLite.SQLiteCachingProvider" /> class. /// </summary> /// <param name="perRequestCacheManager">per request cacheManager</param> /// <param name="connectionWrapper">Connection wrapper</param> /// <param name="config">Config options</param> /// <param name="loggerFactory">Logger Factory</param> public SQLiteCacheManager(ICacheManager perRequestCacheManager, ISQLiteConnectionProvider connectionWrapper, SQLiteConfig config, ILiteXLoggerFactory loggerFactory = null) { if (string.IsNullOrEmpty(config.FileName)) { throw new Exception("FileName is empty"); } if (string.IsNullOrEmpty(config.FilePath)) { throw new Exception("FilePath is empty"); } _config = config; _perRequestCacheManager = perRequestCacheManager; _connectionWrapper = connectionWrapper; _connection = _connectionWrapper.GetConnection(); _logger = (loggerFactory?.CreateLogger(this) ?? new LiteXNullLoggerFactory().CreateLogger(this)); }
/// <summary> /// Adds LiteX SQLite Cache manager services /// </summary> /// <param name="services"></param> /// <param name="options">Option setup.</param> /// <returns></returns> public static IServiceCollection AddLiteXSQLiteCache(this IServiceCollection services, Action <SQLiteConfig> options) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) if (options == null) { throw new ArgumentNullException("options"); } SQLiteConfig sQLiteConfig = new SQLiteConfig(); options(sQLiteConfig); ServiceCollectionServiceExtensions.AddSingleton <SQLiteConfig>(services, sQLiteConfig); services.AddLiteXPerRequestCache(); ServiceCollectionServiceExtensions.AddSingleton <ISQLiteConnectionProvider, SQLiteConnectionProvider>(services); ServiceCollectionServiceExtensions.AddScoped <ILiteXCacheManager, SQLiteCacheManager>(services); ServiceCollectionServiceExtensions.AddScoped <ILiteXCacheManagerAsync, SQLiteCacheManager>(services); return(services); }
/// <summary> /// Initializes a new instance of the <see cref="T:LiteX.Cache.SQLite.SQLiteConnectionProvider" /> class. /// Ctor /// </summary> /// <param name="config">Config</param> public SQLiteConnectionProvider(SQLiteConfig config) { _config = config; }