Example #1
0
            /// <summary>
            ///     Add a key / value pair to the dictionary.
            /// </summary>
            /// <param name="item">
            ///     The <see cref="KeyValuePair{TKey, TValue}"/> to add.
            /// </param>
            public void Add(KeyValuePair <T3, T4> item)
            {
                if (item.Key == null)
                {
                    throw new ArgumentException("Key cannot be null.", nameof(item));
                }

                if (item.Value == null)
                {
                    throw new ArgumentException("Value cannot be null.", nameof(item));
                }

                if (ForwardLookup.ContainsKey(item.Key))
                {
                    throw new ArgumentException("The dictionary's forward-lookup section already contains the specified key.", nameof(item));
                }

                if (ReverseLookup.ContainsKey(item.Value))
                {
                    throw new ArgumentException("The dictionary's reverse-lookup section already contains the specified key.", nameof(item));
                }

                ForwardLookup.Add(item.Key, item.Value);
                ReverseLookup.Add(item.Value, item.Key);
            }
Example #2
0
            /// <summary>
            ///     Add a value to the dictionary with the specified key.
            /// </summary>
            /// <param name="key">
            ///     The key.
            /// </param>
            /// <param name="value">
            ///     The value.
            /// </param>
            public void Add(T3 key, T4 value)
            {
                if (key == null)
                {
                    throw new ArgumentNullException(nameof(key));
                }

                if (value == null)
                {
                    throw new ArgumentNullException(nameof(value));
                }

                if (ForwardLookup.ContainsKey(key))
                {
                    throw new ArgumentException("The dictionary's forward-lookup section already contains the specified key.", nameof(key));
                }

                if (ReverseLookup.ContainsKey(value))
                {
                    throw new ArgumentException("The dictionary's reverse-lookup section already contains the specified key.", nameof(value));
                }

                ForwardLookup.Add(key, value);
                ReverseLookup.Add(value, key);
            }