public DataManager_UnitTest() { fileProvider = ConfigureMoqFileProvider(); jsonProvider = ConfigureJsonProvider(); myTracing = ConfigureTracingProvider(); dataManager = new DataManager(fileProvider, jsonProvider, myTracing); }
private static IHostBuilder CreateHostBuilder() { return(Host.CreateDefaultBuilder() .ConfigureServices(services => services.AddSingleton <IDownloadTaskFactory <IllustrationViewModel, ObservableDownloadTask>, IllustrationDownloadTaskFactory>() .AddSingleton(new SQLiteAsyncConnection(AppContext.DatabaseFilePath, SQLiteOpenFlags.Create | SQLiteOpenFlags.FullMutex | SQLiteOpenFlags.ReadWrite)) .AddSingleton(provider => IPersistentManager <DownloadHistoryEntry, ObservableDownloadTask> .CreateAsync <DownloadHistoryPersistentManager>(provider.GetRequiredService <SQLiteAsyncConnection>(), App.AppViewModel.AppSetting.MaximumDownloadHistoryRecords)) .AddSingleton(provider => IPersistentManager <SearchHistoryEntry, SearchHistoryEntry> .CreateAsync <SearchHistoryPersistentManager>(provider.GetRequiredService <SQLiteAsyncConnection>(), App.AppViewModel.AppSetting.MaximumSearchHistoryRecords)))); }
public void FileProvider() { IPersistentManager fileProvider = null; using (IUnityContainer container = new UnityContainer()) { InternationalBusinessServiceLibrary.Unity.ConfigureUnity.Configure(container); fileProvider = container.Resolve <IPersistentManager>(); } Assert.IsNotNull(fileProvider); }
public void FileProvider() { IPersistentManager fileProvider = null; using (IUnityContainer container = new UnityContainer()) { UnityConfig.RegisterTypes(container); fileProvider = container.Resolve <IPersistentManager>(); } Assert.IsNotNull(fileProvider); }
public DataManager(IPersistentManager fileProvider, IDataProvider jsonProvider, ITracing myTracing) { this._fileProvider = fileProvider; this._jsonProvider = jsonProvider; this._myTracing = myTracing; }
public static async Task <IDictionary <Guid, int> > LoadDownloadedFeedsAsync(IDictionary <Guid, Feed> subscribedFeeds, IPersistentManager dbContext) { if (subscribedFeeds == null) { return(null); } var downloadedFiles = StorageHelper.GetLocalFilesStartWith(AppConfig.TEMP_DOWNLOAD_FILE_PATTERN); IDictionary <Guid, int> updatedFeeds = null; if (downloadedFiles != null && downloadedFiles.Count() > 0) { updatedFeeds = new Dictionary <Guid, int>(); foreach (var fileName in downloadedFiles) { var updated = await UpdateDownloadedFeedsAsync(subscribedFeeds, fileName, dbContext); if (updated != null && updated.Count > 0) { updated.ForEach(u => { if (updatedFeeds.ContainsKey(u.Key)) { updatedFeeds[u.Key] += u.Value; } else { updatedFeeds.Add(u.Key, u.Value); } }); } StorageHelper.DeleteFile(fileName); } } AppConfig.FeedDownloads = null; return(updatedFeeds); }
private static async Task <IDictionary <Guid, int> > UpdateDownloadedFeedsAsync(IDictionary <Guid, Feed> subscribedFeeds, string fileName, IPersistentManager dbContext) { var feedsUpdated = await dbContext.ReadSerializedCopyAsync <List <Feed> >(fileName); if (feedsUpdated == null || feedsUpdated.Count == 0) { return(null); } var updatedFeeds = new Dictionary <Guid, int>(); feedsUpdated.ForEach(f => { if (!subscribedFeeds.ContainsKey(f.Id)) { return; } var persistentFeed = subscribedFeeds[f.Id]; var updatedItemCount = FeedHelper.UpdateFeedItems(persistentFeed, f.Items); if (updatedItemCount > 0) { updatedFeeds.Add(persistentFeed.Id, updatedItemCount); } persistentFeed.LastUpdatedTime = f.LastUpdatedTime; }); return(updatedFeeds); }
/// <summary> /// Delegate allows the Consistent to notify parent it requires an update. /// </summary> /// <param name="delegateInstance"></param> public void InitializePersistency(IPersistentManager manager) { _manager = manager; }
public abstract bool OnRestoreState(IPersistentManager manager, PersistentData data);
public abstract bool OnSaveState(IPersistentManager manager, PersistentData data);
/// <summary> /// Delegate allows the Consistent to notify parent it requires an update. /// </summary> /// <param name="delegateInstance"></param> public void InitializePersistency(IPersistentManager manager) { _manager = manager; }