/ Published in: C#
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
/* * FileName: objectList.cs * Classes Included: objectList * Purpose: The objectList is a class that contains Name-Value pairs that can be * accessed as per the NameValueCollection, but the value is an arbitrary * non-typed object that must be boxed on removal. * Created on: 27 May 2009 * Created by: wraith808 * * History: * Date Who Note * --------------------------------------------------------------------------- * 05-27-2009 wraith808 Created * */ using System; using System.Collections.Generic; using System.Text; using System.Collections.Specialized; using System.Collections; namespace UtilsLib { public class objectList : NameObjectCollectionBase { // Creates an empty collection. public objectList() { } // Adds elements from an IDictionary into the new collection. public objectList(IDictionary d, Boolean readOnly) { foreach ( DictionaryEntry de in d ) { this.BaseAdd( (string) de.Key, de.Value ); } this.IsReadOnly = readOnly; } // Gets a key-and-value pair (DictionaryEntry) using an index. public DictionaryEntry this[ int index ] { get { this.BaseGetKey(index), this.BaseGet(index) ) ); } } // Gets or sets the value associated with the specified key. public Object this[ string key ] { get { return( this.BaseGet( key ) ); } set { this.BaseSet( key, value ); } } // Gets a String array that contains all the keys in the collection. public string[] AllKeys { get { return( this.BaseGetAllKeys() ); } } // Gets an Object array that contains all the values in the collection. public Array AllValues { get { return( this.BaseGetAllValues() ); } } // Gets a String array that contains all the values in the collection. public string[] AllStringValues { get { } } // Gets a value indicating if the collection contains keys that are not null. public Boolean HasKeys { get { return( this.BaseHasKeys() ); } } // Adds an entry to the collection. public void Add( string key, Object value ) { this.BaseAdd( key, value ); } // Removes an entry with the specified key from the collection. public void Remove( string key ) { this.BaseRemove( key ); } // Removes an entry in the specified index from the collection. public void Remove( int index ) { this.BaseRemoveAt( index ); } // Clears all the elements in the collection. public void Clear() { this.BaseClear(); } } }