コード例 #1
0
        private void SaveInternal(UserAccounts userAccounts, UserAccount userAccount)
        {
            UserAccounts userAccountsToSave = new UserAccounts();

            foreach (UserAccount ua in userAccounts.Accounts.Where(a => a.UserName != userAccount.UserName))
            {
                userAccountsToSave.Accounts.Add(ua);
            }
            userAccountsToSave.Accounts.Add(userAccount);

            using (StreamWriter writer = new StreamWriter(_workContainer.FileItemInfo("UserAccounts.txt").OpenWrite()))
            {
                userAccountsToSave.SerializeTo(writer);
            }
        }
コード例 #2
0
        public async Task TestEncryptFilesUniqueWithBackupAndWipeWithCollision()
        {
            IDataStore sourceFileInfo = New <IDataStore>(_davidCopperfieldTxtPath);

            sourceFileInfo.Container.CreateFolder();
            IDataContainer sourceFolderInfo = sourceFileInfo.Container;

            sourceFolderInfo.CreateNewFile("David Copperfield-txt.axx");
            IDataStore alternateDestinationFileInfo = sourceFolderInfo.FileItemInfo("David Copperfield-txt.1.axx");

            Assert.That(alternateDestinationFileInfo.IsAvailable, Is.False, "The destination should not be created and exist yet.");

            EncryptionParameters encryptionParameters = new EncryptionParameters(new V2Aes128CryptoFactory().CryptoId, new Passphrase("allan"));

            await New <AxCryptFile>().EncryptFoldersUniqueWithBackupAndWipeAsync(new IDataContainer[] { sourceFolderInfo }, encryptionParameters, new ProgressContext());

            Assert.That(sourceFileInfo.IsAvailable, Is.False, "The source should be wiped.");

            Assert.That(alternateDestinationFileInfo.IsAvailable, Is.True, "The destination should be created and exist now.");
        }