public VisitingViewModel(Func <IServiceProvider, IComicVisiting <TImage> > visiting = null, bool ignoreVisting = false) { scope = AppEngine.CreateScope(); provider = scope.ServiceProvider; InitService(scope.ServiceProvider, visiting, ignoreVisting); InitVisiting(); }
public HomeViewModel() { ComicEngine = AppEngine.GetRequiredService <ComicEngine>(); SearchEngine = AppEngine.GetRequiredService <SearchEngine>(); ProposalEngine = AppEngine.GetRequiredService <ProposalEngine>(); SearchCommand = new AsyncRelayCommand(SearchAsync); GoSourceCommand = new RelayCommand(GoSource); SetAndSearchCommand = new AsyncRelayCommand <string>(SetAndSearchAsync); ResetCommand = new RelayCommand(Reset); SetCurrentCommand = new RelayCommand <ComicSnapshotInfo <TSourceInfo> >(SetCurrent); CopyCommand = new RelayCommand <string>(Copy); scope = AppEngine.CreateScope(); observableCollectionFactory = AppEngine.GetRequiredService <IObservableCollectionFactory>(); SearchProviders = observableCollectionFactory.Create <ISearchProvider>(); foreach (var item in SearchEngine) { var sp = (ISearchProvider)scope.ServiceProvider.GetRequiredService(item); SearchProviders.Add(sp); } CurrentSearchProvider = SearchProviders.FirstOrDefault(); Snapshots = observableCollectionFactory.Create <ComicSnapshotInfo <TSourceInfo> >(); ProposalSnapshots = observableCollectionFactory.Create <ComicSnapshotInfo <TSourceInfo> >(); EngineIcons = observableCollectionFactory.Create <EngineInfo <TImage> >(); }
public void GetServiceScope_MustNotNull() { AppEngine.Reset(); var scope = AppEngine.CreateScope(); Assert.IsNotNull(scope); scope.Dispose(); }
public ComicKeeper(string address, string imageFolderName, IStoreService storeService = null, IStoreService fetchService = null) { Address = address; ImageFolderName = imageFolderName; HasImageFolderName = !string.IsNullOrEmpty(imageFolderName); scope = AppEngine.CreateScope(); var engine = scope.ServiceProvider.GetRequiredService <ComicEngine>(); var condition = engine.GetComicSourceProviderType(address); if (condition != null) { Provider = (IComicSourceProvider)scope.ServiceProvider.GetRequiredService(condition.ProviderType); } else { NotSupport = true; } this.storeService = storeService ?? scope.ServiceProvider.GetRequiredService <IStoreService>(); this.fetchService = fetchService ?? this.storeService; tokenSource = new CancellationTokenSource(); }