/// <summary> /// Initializes the commands and sets <see cref="CredentialTokens"/> to an empty collection. /// The ViewModel must be activated before use. /// </summary> /// <param name="accessList">A list used to look up candidates to get their underlying files.</param> /// <param name="exportService">Used to export stored files.</param> /// <param name="proxyProvider">Provider to use for accessing stored databases.</param> /// <param name="deletePrompter">Service to use for prompting user consent/understanding.</param> /// <param name="updatePrompter">Service to use for prompting user consent/understanding.</param> /// <param name="fileService">Service to use for accessing the filesystem.</param> public CachedFilesViewModel( IDatabaseAccessList accessList, IFileExportService exportService, IFileProxyProvider proxyProvider, IUserPromptingService deletePrompter, IUserPromptingService updatePrompter, IFileAccessService fileService ) : base(accessList, proxyProvider, exportService, deletePrompter, updatePrompter, fileService) { this.accessList = accessList; this.proxyProvider = proxyProvider; this.deleteAllCommand = new AsyncActionCommand( async() => { if (await this.proxyProvider.TryDeleteAllProxiesAsync() .ConfigureAwait(false) ) { ClearAllFiles(); } else { // If clearing wasn't successful we might need to add back some // files. await ResyncFiles(); } } ); }
/// <summary> /// Initializes the ViewModel with the <see cref="IStorageItemAccessList"/> provided. /// </summary> /// <param name="accessList">The access list used to populate the RecentDatabases collection.</param> /// <param name="motdProvider">Used to provide the message-of-the-day.</param> /// <param name="proxyProvider">Used to generate database proxy files in the roaming directory.</param> /// <param name="exportService">Used to export copies of cached files.</param> /// <param name="deletePrompter">Used to prompt the user for consent/understanding.</param> /// <param name="updatePrompter">Used to prompt the user for consent/understanding.</param> /// <param name="fileService">Used to access the filesystem.</param> public DashboardViewModel( IDatabaseAccessList accessList, IMotdProvider motdProvider, IFileProxyProvider proxyProvider, IFileExportService exportService, IUserPromptingService deletePrompter, IUserPromptingService updatePrompter, IFileAccessService fileService ) : base(accessList, proxyProvider, exportService, deletePrompter, updatePrompter, fileService) { this.motdProvider = motdProvider ?? throw new ArgumentNullException(nameof(motdProvider)); this.proxyProvider = proxyProvider ?? throw new ArgumentNullException(nameof(proxyProvider)); }
public CachedFilesViewModelFactory( IDatabaseAccessList accessList, IFileExportService exportService, IFileProxyProvider proxyProvider, IUserPromptingService deletePrompter, IUserPromptingService updatePrompter, IFileAccessService fileService ) { this.accessList = accessList ?? throw new ArgumentNullException(nameof(accessList)); this.exportService = exportService ?? throw new ArgumentNullException(nameof(exportService)); this.proxyProvider = proxyProvider ?? throw new ArgumentNullException(nameof(proxyProvider)); this.deletePrompter = deletePrompter ?? throw new ArgumentNullException(nameof(deletePrompter)); this.updatePrompter = updatePrompter ?? throw new ArgumentNullException(nameof(updatePrompter)); this.fileService = fileService ?? throw new ArgumentNullException(nameof(fileService)); }
/// <summary> /// Initializes the instance with the services needed to export files. /// </summary> /// <param name="accessList">Used to retrieve files from stored tokens.</param> /// <param name="proxyProvider">Used to manage underlying cached file proxies.</param> /// <param name="exportService">The service used to export databases.</param> /// <param name="deletePrompter">A service used to prompt the user for consent to delete a file.</param> /// <param name="updatePrompter">A service used to prompt the user for consent to update a file.</param> /// <param name="fileService">A service used to access the filesystem.</param> protected CachedFileExportingViewModel( IDatabaseAccessList accessList, IFileProxyProvider proxyProvider, IFileExportService exportService, IUserPromptingService deletePrompter, IUserPromptingService updatePrompter, IFileAccessService fileService ) { this.accessList = accessList ?? throw new ArgumentNullException(nameof(accessList)); this.proxyProvider = proxyProvider ?? throw new ArgumentNullException(nameof(proxyProvider)); this.exportService = exportService ?? throw new ArgumentNullException(nameof(exportService)); this.deletePrompter = deletePrompter ?? throw new ArgumentNullException(nameof(deletePrompter)); this.updatePrompter = updatePrompter ?? throw new ArgumentNullException(nameof(updatePrompter)); this.fileService = fileService ?? throw new ArgumentNullException(nameof(fileService)); this.data = new ObservableCollection <StoredFileDescriptor>( this.accessList.Entries.Select(entry => new StoredFileDescriptor(entry)) ); this.readOnlyData = new ReadOnlyObservableCollection <StoredFileDescriptor>(this.data); }