コード例 #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);
        }
コード例 #3
0
        /// <inheritdoc />
        bool IDictionary <TIndex, TValue> .TryGetValue(TIndex index, out TValue value)
        {
            IDictionaryContracts.TryGetValue(index);

            return(this.dictionary.TryGetValue(index, out value));
        }
コード例 #4
0
        /// <inheritdoc />
        public bool TryGetValue(Type key, out TBase value)
        {
            IDictionaryContracts.TryGetValue(key);

            return(this.values.TryGetValue(key, out value));
        }
コード例 #5
0
        /// <inheritdoc />
        public virtual bool TryGetValue(TKey key, out TValue value)
        {
            IDictionaryContracts.TryGetValue(key);

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