/// <summary>
 /// Initializes a new instance of the <see cref="ReversibleDictionary{TKey,TValue}"/> class that
 /// uses the provided <see cref="IEqualityComparer{T}"/> for <typeparamref name="TKey"/> and
 /// <typeparamref name="TValue"/>.
 /// </summary>
 /// <param name="keyComparer"> The <see cref="IEqualityComparer{T}"/> implementation to use when comparing
 /// keys, or <see langword="null"/> to use the default <see cref="EqualityComparer{T}"/> for the type
 /// of the key.
 /// </param>
 /// <param name="valueComparer"> The <see cref="IEqualityComparer{T}"/> implementation to use when comparing
 /// values, or <see langword="null"/> to use the default <see cref="EqualityComparer{T}"/> for the type
 /// of the values.</param>
 public ReversibleDictionary(
     IEqualityComparer <TKey> keyComparer,
     IEqualityComparer <TValue> valueComparer)
 {
     this.Key2Value = new Dictionary <TKey, TValue>(keyComparer);
     this.Value2Key = new Dictionary <TValue, TKey>(valueComparer);
     this.reversed  = new ReversibleDictionary <TValue, TKey>(this.Value2Key, this.Key2Value, this);
 }
        public void OnDeserialization(object sender)
        {
            if (this.SInfo == null)
            {
                return;
            }

            KeyValuePair <TKey, TValue>[] serializedKey2Value = this.DeserializeElements();

            IEqualityComparer <TKey>   serializedKey2ValueComparer;
            IEqualityComparer <TValue> serializedValue2KeyComparer;

            this.Key2Value = this.TryDeserializeValue(KeyEqualityComparerName, out serializedKey2ValueComparer, sender)
                ? new Dictionary <TKey, TValue>(serializedKey2ValueComparer)
                : new Dictionary <TKey, TValue>();

            this.Value2Key = this.TryDeserializeValue(ValueEqualityComparerName, out serializedValue2KeyComparer, sender)
                 ? new Dictionary <TValue, TKey>(serializedValue2KeyComparer)
                 : new Dictionary <TValue, TKey>();

            this.reversed = new ReversibleDictionary <TValue, TKey>(this.Value2Key, this.Key2Value, this);
            this.AddAll(serializedKey2Value);
            this.SInfo = null;
        }