Ejemplo n.º 1
0
        /// <inheritdoc />
        public override bool TryGetValue(TKey key, out TValue value)
        {
            IDictionaryContracts.TryGetValue(key);

            if (!this.Dictionary.TryGetValue(key, out value))
            {
                value = this.producer(key);
                this.Dictionary[key] = value;
            }

            return(true);
        }
        /// <inheritdoc />
        public bool TryGetValue(TIndex key, out TValue value)
        {
            IDictionaryContracts.TryGetValue(key);
            IReadOnlyIndexableContracts.TryGetValue(this, key);

            TryValue <TValue> result;

            if (this.indexable.TryGetValue(key, out result))
            {
                if (result.HasValue)
                {
                    value = result.Value;
                    return(true);
                }
            }

            // either the try get failed or the result had no value. Failure either way
            value = default(TValue);
            return(false);
        }
        /// <inheritdoc />
        bool IDictionary <TIndex, TValue> .TryGetValue(TIndex index, out TValue value)
        {
            IDictionaryContracts.TryGetValue(index);

            return(this.dictionary.TryGetValue(index, out value));
        }
Ejemplo n.º 4
0
        /// <inheritdoc />
        public bool TryGetValue(Type key, out TBase value)
        {
            IDictionaryContracts.TryGetValue(key);

            return(this.values.TryGetValue(key, out value));
        }
        /// <inheritdoc />
        public virtual bool TryGetValue(TKey key, out TValue value)
        {
            IDictionaryContracts.TryGetValue(key);

            return(this.Dictionary.TryGetValue(key, out value));
        }