コード例 #1
0
        public virtual Boolean TryAdd([NotNull] TKey key, [NotNull] TValue value)
        {
            if (key is null)
            {
                throw new ArgumentNullException(nameof(key));
            }

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

            if (ContainsKey(key) || ContainsValue(value))
            {
                return(false);
            }

            Boolean added = Base.TryAdd(key, value);

            if (added ^ Reversed.TryAdd(value, key))
            {
                throw new CollectionSyncException();
            }

            return(added);
        }