コード例 #1
0
        /// <inheritdoc />
        TValue IDictionary <TIndex, TValue> .this[TIndex index]
        {
            get
            {
                IDictionaryContracts.IndexerGet(this, index);

                return(this.dictionary[index]);
            }

            set
            {
                IDictionaryContracts.IndexerSet(this, index);

                this.dictionary[index] = value;
            }
        }
コード例 #2
0
        /// <inheritdoc />
        public virtual TValue this[TKey key]
        {
            get
            {
                IDictionaryContracts.IndexerGet(this, key);

                return(this.Dictionary[key]);
            }

            set
            {
                IDictionaryContracts.IndexerSet(this, key);

                this.Dictionary[key] = value;
            }
        }
コード例 #3
0
        /// <inheritdoc />
        public override TValue this[TKey key]
        {
            get
            {
                IDictionaryContracts.IndexerGet(this, key);

                TValue result;
                this.TryGetValue(key, out result);
                return(result);
            }

            set
            {
                IDictionaryContracts.IndexerSet(this, key);

                this.Dictionary[key] = value;
            }
        }
コード例 #4
0
        /// <inheritdoc />
        public override TValue this[TKey key]
        {
            get
            {
                IDictionaryContracts.IndexerGet(this, key);

                return(this.Dictionary[key]);
            }

            set
            {
                IDictionaryContracts.IndexerSet(this, key);

                if (this.addValue(KeyValuePair.New(key, value)))
                {
                    this.Dictionary[key] = value;
                }
            }
        }
        /// <inheritdoc />
        public TValue this[TIndex index]
        {
            // this method's contracts will check that the dictionary contains the key first
            get
            {
                IDictionaryContracts.IndexerGet(this, index);
                IReadOnlyIndexableContracts.IndexerGet(this, index);

                return(this.indexable[index].Value);
            }

            set
            {
                IDictionaryContracts.IndexerSet(this, index);
                IIndexableContracts.IndexerSet(this, index);

                if (!this.indexable[index].HasValue)
                {
                    this.count++;
                }

                this.indexable[index] = TryValue.New(value);
            }
        }