/// <summary> /// Called during serialization to encrypt a property value /// </summary> public void SetValue(object target, object value) { string encryptedText = value as string; if (!string.IsNullOrEmpty(encryptedText)) { PropertyInfo.SetValue(target, DataProtection.Decrypt(encryptedText, Scope)); } }
internal void OnDeserializedMethod(StreamingContext context) { try { string sourceString = DataProtection.Decrypt(SourceString, Scope); var keyPairs = sourceString.Split(PairSeparator); foreach (var kp in keyPairs) { string[] parts = kp.Split(KeyValueSeparator); if (parts.Length == 2) { Contents.Add(parts[0].Trim(), parts[1].Trim()); } } SourceString = null; } catch (Exception exc) { throw new Exception($"Error deserializing SecureDictionary: {exc.Message}", exc); } }