// Internal constructor for initializing fields and checking edge cases private KdbxDecryptionResult(ReaderResult error, KdbxSerializationParameters kdbxParameters, KdbxDocument document, IBuffer rawKey) { DebugHelper.Assert(error != null); if (error == null) { throw new ArgumentNullException(nameof(error)); } if (error != ReaderResult.Success) { DebugHelper.Assert(document == null); if (document != null) { throw new ArgumentException("If error is defined, the other arguments must be null"); } } else { // Result is guaranteed to be Success at this point DebugHelper.Assert(document != null); if (document == null) { throw new ArgumentNullException(nameof(document)); } if (rawKey == null) { throw new ArgumentNullException(nameof(rawKey)); } } Result = error; this.kdbxParameters = kdbxParameters; this.kdbxDocument = document; this.rawKey = rawKey; }
/// <summary> /// Constructor for a failed decryption /// </summary> /// <param name="error">The failure case of the decryption - must not be none</param> public KdbxDecryptionResult(ReaderResult error) : this(error, null, null, null) { }