System.Runtime.Remoting.Channels.TransportHeaders.this C# (CSharp) Method

this() public method

public this ( Object key ) : Object
key Object
return Object
        public Object this[Object key]
        {
            get 
            {
                String strKey = (String)key;
                
                // look for matching key in header list
                foreach (DictionaryEntry entry in _headerList)
                {
                    if (String.Compare((String)entry.Key, strKey, StringComparison.OrdinalIgnoreCase) == 0)
                        return entry.Value;                    
                }

                // entry not found
                return null;
            } // get

            set
            {
                if (key == null)
                    return;

                String strKey = (String)key;

                // remove this entry if it's already in the list
                int co = _headerList.Count - 1;
                while (co >= 0)
                {                
                    String headerKey = (String)((DictionaryEntry)_headerList[co]).Key;
                    if (String.Compare(headerKey, strKey, StringComparison.OrdinalIgnoreCase) == 0)
                    {
                        _headerList.RemoveAt(co);
                        break;
                    }
                    co--;
                }

                // otherwise, add this entry
                if (value != null)
                {
                    _headerList.Add(new DictionaryEntry(key, value));
                }
            } // set
        } // Object this[Object key]