public SqliteRepository(ISQLitePlatform platform, ILocalStorage storage, DbPath dbpath, string dbfile = "data.db") { string dbFullPath = Path.Combine(dbpath.Path, dbfile); this.connectionString = new SQLiteConnectionString(dbFullPath, true, openFlags: SQLiteOpenFlags.ReadWrite | SQLiteOpenFlags.Create | SQLiteOpenFlags.FullMutex | SQLiteOpenFlags.SharedCache); this.platform = platform; this.storage = storage; this.dbPath = Path.GetDirectoryName(this.connectionString.DatabasePath); }
private void Synchronize(IMemoryRepository memoryInstance, Type memoryType, Type storageType) { try { Type[] typeArgs = { memoryType }; Type constructed = storageType.MakeGenericType(typeArgs); string dbPath = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "data"); var storageInstance = (IStorageRepository)Activator.CreateInstance(constructed, new SQLitePlatformWinRT(), new LocalStorage(), DbPath.Create(dbPath), "data.db"); StorageSynchronize(memoryInstance, memoryType, storageInstance); storageContext.Add(storageInstance); } catch { throw new Exception("Repository Manager :: cannot synchronize service"); } }