<PackageReference Include="Relativity.Server.Import.SDK" Version="2.9.2" />

AppSettingsDictionary

Defines a custom dictionary that applies all changes to the injected IAppSettings instance.
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; namespace Relativity.DataExchange { [SuppressMessage("Microsoft.Design", "CA1035:ICollectionImplementationsHaveStronglyTypedMembers", Justification = "This isn't required.")] internal class AppSettingsDictionary : IDictionary, ICollection, IEnumerable { private readonly Dictionary<object, object> dictionary = new Dictionary<object, object>(); private readonly IAppSettings settings; public int Count => dictionary.Count; public bool IsFixedSize => ((IDictionary)dictionary).IsFixedSize; public bool IsReadOnly => ((IDictionary)dictionary).IsReadOnly; public bool IsSynchronized => ((ICollection)dictionary).IsSynchronized; public ICollection Keys => dictionary.Keys; public object SyncRoot => ((ICollection)dictionary).SyncRoot; public ICollection Values => dictionary.Values; public object this[object key] { get { if (key == null) throw new ArgumentNullException("key"); return dictionary[key]; } set { if (key == null) throw new ArgumentNullException("key"); dictionary[key] = value; AppSettingsManager.SetDynamicValue(settings, key.ToString(), (value != null) ? value.ToString() : string.Empty); } } public AppSettingsDictionary(IAppSettings settings) { if (settings == null) throw new ArgumentNullException("settings"); this.settings = settings; AppSettingsManager.Copy(settings, this); } public void Add(object key, object value) { if (key == null) throw new ArgumentNullException("key"); dictionary.Add(key, value); AppSettingsManager.SetDynamicValue(settings, key.ToString(), (value != null) ? value.ToString() : string.Empty); } public void Clear() { dictionary.Clear(); } public bool Contains(object key) { return dictionary.ContainsKey(key); } public void CopyTo(Array array, int index) { ((ICollection)dictionary).CopyTo(array, index); } IEnumerator IEnumerable.GetEnumerator() { return dictionary.GetEnumerator(); } public IDictionaryEnumerator GetEnumerator() { return dictionary.GetEnumerator(); } public void Remove(object key) { dictionary.Remove(key); } } }