00001 using System; 00002 using System.Collections; 00003 using System.Data; 00004 00005 namespace SQLiteCSLib 00006 { 00010 public class SQLiteParameterCollection : ArrayList, IDataParameterCollection 00011 { 00015 public SQLiteParameterCollection() 00016 { 00017 } 00018 00022 public object this[string parameterName] 00023 { 00024 get 00025 { 00026 foreach( IDataParameter idp in this ) 00027 { 00028 if( idp.ParameterName == parameterName ) 00029 return idp; 00030 } 00031 00032 return null; 00033 } 00034 set 00035 { 00036 IDataParameter target = null; 00037 foreach( IDataParameter idp in this ) 00038 { 00039 if( idp.ParameterName == parameterName ) 00040 target = idp; 00041 } 00042 00043 if( target != null ) 00044 { 00045 this.Remove( target ); 00046 this.Add( value ); 00047 } 00048 } 00049 } 00050 00055 public void RemoveAt(string parameterName) 00056 { 00057 IDataParameter target = null; 00058 foreach( IDataParameter idp in this ) 00059 { 00060 if( idp.ParameterName == parameterName ) 00061 target = idp; 00062 } 00063 00064 if( target != null ) 00065 { 00066 this.Remove( target ); 00067 } 00068 } 00069 00075 public bool Contains(string parameterName) 00076 { 00077 foreach( IDataParameter idp in this ) 00078 { 00079 if( idp.ParameterName == parameterName ) 00080 return true; 00081 } 00082 00083 return false; 00084 } 00085 00092 public int IndexOf(string parameterName) 00093 { 00094 for( int iIdx = 0; iIdx<this.Count; iIdx++ ) 00095 { 00096 IDataParameter idp = this[ iIdx ] as IDataParameter; 00097 if( idp != null && idp.ParameterName.ToUpper() == parameterName.ToUpper() ) 00098 return iIdx; 00099 } 00100 00101 return -1; 00102 } 00103 } 00104 }