/// <summary> /// Initializes a new instance of the class. /// </summary> /// <param name="syncContext">Synchronization context used for marshalling to the UI thread.</param> /// <param name="file">The candidate document file.</param> /// <param name="isSampleFile">Whether the file is a PassKeep sample.</param> /// <param name="futureAccessList">A database access list for persisting permission to the database.</param> /// <param name="reader">The IKdbxReader implementation used for parsing document files.</param> /// <param name="proxyProvider">Generates file proxies that the app controls.</param> /// <param name="candidateFactory">Factory used to generate new candidate files as needed.</param> /// <param name="keyChangeVmFactory">Factory used to generate the objects used to modify the master key of the database.</param> /// <param name="taskNotificationService">A service used to notify the UI of blocking operations.</param> /// <param name="identityService">The service used to verify the user's consent for saving credentials.</param> /// <param name="credentialProvider">The provider used to store/load saved credentials.</param> /// <param name="credentialViewModelFactory">A factory used to generate <see cref="ISavedCredentialsViewModel"/> instances.</param> public DatabaseUnlockViewModel( ISyncContext syncContext, IDatabaseCandidate file, bool isSampleFile, IDatabaseAccessList futureAccessList, IKdbxReader reader, IFileProxyProvider proxyProvider, IDatabaseCandidateFactory candidateFactory, IMasterKeyChangeViewModelFactory keyChangeVmFactory, ITaskNotificationService taskNotificationService, IIdentityVerificationService identityService, ICredentialStorageProvider credentialProvider, ISavedCredentialsViewModelFactory credentialViewModelFactory ) { this.syncContext = syncContext ?? throw new ArgumentNullException(nameof(syncContext)); this.futureAccessList = futureAccessList; this.kdbxReader = reader ?? throw new ArgumentNullException(nameof(reader)); this.proxyProvider = proxyProvider ?? throw new ArgumentNullException(nameof(proxyProvider)); this.candidateFactory = candidateFactory ?? throw new ArgumentNullException(nameof(candidateFactory)); this.keyChangeVmFactory = keyChangeVmFactory ?? throw new ArgumentNullException(nameof(keyChangeVmFactory)); this.taskNotificationService = taskNotificationService ?? throw new ArgumentNullException(nameof(taskNotificationService)); this.identityService = identityService ?? throw new ArgumentNullException(nameof(identityService)); this.credentialProvider = credentialProvider ?? throw new ArgumentNullException(nameof(credentialProvider)); this.credentialViewModelFactory = credentialViewModelFactory ?? throw new ArgumentNullException(nameof(credentialViewModelFactory)); SaveCredentials = false; IdentityVerifiability = UserConsentVerifierAvailability.Available; UnlockCommand = new AsyncActionCommand(CanUnlock, DoUnlockAsync); UseSavedCredentialsCommand = new AsyncActionCommand( () => UnlockCommand.CanExecute(null) && HasSavedCredentials, DoUnlockWithSavedCredentials ); IsSampleFile = isSampleFile; RememberDatabase = true; this.initialConstruction = UpdateCandidateFileAsync(file); }
public DatabaseCreationViewModel( ISyncContext syncContext, ITestableFile file, IDatabaseSettingsViewModelFactory settingsVmFactory, IMasterKeyChangeViewModelFactory keyChangeVmFactory, IKdbxWriterFactory writerFactory, IDatabaseAccessList futureAccessList, ITaskNotificationService taskNotificationService, IDatabaseCandidateFactory candidateFactory, IFileAccessService fileAccessService ) : base(fileAccessService) { this.syncContext = syncContext ?? throw new ArgumentNullException(nameof(syncContext)); File = file ?? throw new ArgumentNullException(nameof(file)); Settings = settingsVmFactory?.Assemble() ?? throw new ArgumentNullException(nameof(settingsVmFactory)); this.keyChangeVmFactory = keyChangeVmFactory ?? throw new ArgumentNullException(nameof(keyChangeVmFactory)); this.writerFactory = writerFactory ?? throw new ArgumentNullException(nameof(writerFactory)); this.futureAccessList = futureAccessList ?? throw new ArgumentNullException(nameof(futureAccessList)); this.taskNotificationService = taskNotificationService ?? throw new ArgumentNullException(nameof(taskNotificationService)); this.candidateFactory = candidateFactory ?? throw new ArgumentNullException(nameof(candidateFactory)); CreateEmpty = true; Remember = true; }