public void Run(TWorkflowOptions workflowDetails) { Contract.Requires <ArgumentNullException>(workflowDetails != null, "options"); Contract.Requires <ArgumentException>(!string.IsNullOrWhiteSpace(workflowDetails.CategoryName), "category name cannot be null or whitespace"); Contract.Requires <ArgumentException>(!string.IsNullOrWhiteSpace(workflowDetails.DatFilePath), "DAT file path cannot be null or whitespace"); Contract.Requires <ArgumentException>(!string.IsNullOrWhiteSpace(workflowDetails.EntryName), "entry name cannot be null or whitespace"); // PlainText decryption doesn't require a key //Contract.Requires<ArgumentException>(typeof(TKey) == typeof(PlainTextKey) || !string.IsNullOrWhiteSpace(options.KeyFilePath), "key file path cannot be null or whitespace"); Contract.Requires <ArgumentException>(!string.IsNullOrEmpty(workflowDetails.StringToEncrypt), "string to encrypt cannot be null or empty"); // /* * Get key from file * Get Entries from file or create a new file if not already there * * Map keys to entries * Encrypt value using key (or leave in plain text) * Add encrypted value to POCO * Write POCO to file */ TKey key; var encryptedSegments = _encryptWorkflow.GetEncryptedSegments(GetKeyLoaderDetails(workflowDetails), workflowDetails.StringToEncrypt, out key); var datPoco = _datLoader.Load(GetDatLoaderOptions(workflowDetails)); datPoco.AddEntry(workflowDetails.CategoryName, workflowDetails.EntryName, key, encryptedSegments, false); _datSaver.Save(datPoco, GetDatSaverOptions(workflowDetails)); }
public void Run(TDatLoaderOptions datLoaderOptions, IList <CategoryEntryPair> entriesToRemove, TDatSaverOptions datSaverOptions) { var dat = _datLoader.Load(datLoaderOptions); for (uint entryI = 0; entryI < entriesToRemove.Count; entryI++) { var currentEntryToRemove = entriesToRemove[(int)entryI]; dat.RemoveEntry(currentEntryToRemove.Category, currentEntryToRemove.Entry); } _datSaver.Save(dat, datSaverOptions); }