You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
DS7/WebSqlHelper/SqlMap.cs

193 lines
4.6 KiB
C#

using System;
using System.Collections.Generic;
using System.Text;
using System.Data.Common;
using System.Collections;
namespace WebSqlHelper
{
public class SqlMapInfo
{
public string Sql;
public DbParameter[] Param;
public string Name;
public SqlMapInfo(string name, string sql, params DbParameter[] para)
{
Sql = sql;
if (para != null && para.Length > 0)
{
Param = new DbParameter[para.Length];
para.CopyTo(Param, 0);
}
Name = name;
}
}
[Serializable()]
public class SqlMapCollection : CollectionBase
{
public SqlMapCollection()
{
}
public SqlMapCollection(SqlMapCollection value)
{
this.AddRange(value);
}
public SqlMapCollection(SqlMapInfo[] value)
{
this.AddRange(value);
}
public string[] Name
{
get
{
string[] s = new string[Count];
for (int i = 0; i < this.Count; i++)
{
s[i] = this[i].Name;
}
return s;
}
}
public DbParameter[] Param
{
get
{
List<DbParameter> param = new List<DbParameter>();
for (int i = 0; i < this.Count; i++)
{
if (this[i].Param != null && this[i].Param.Length > 0)
param.AddRange(this[i].Param);
}
return param.ToArray();
}
}
public int Add(SqlMapInfo value)
{
return base.List.Add(value);
}
public void AddRange(SqlMapInfo[] value)
{
for (int num1 = 0; num1 < value.Length; num1++)
{
this.Add(value[num1]);
}
}
public void AddRange(SqlMapCollection value)
{
for (int num1 = 0; num1 < value.Count; num1++)
{
this.Add((SqlMapInfo)value.List[num1]);
}
}
public bool Contains(SqlMapInfo value)
{
return base.List.Contains(value);
}
public void CopyTo(SqlMapInfo[] array, int index)
{
base.List.CopyTo(array, index);
}
public SqlMapCollectionEnumerator GetEnumerator()
{
return new SqlMapCollectionEnumerator(this);
}
public int IndexOf(SqlMapInfo value)
{
return base.List.IndexOf(value);
}
public void Insert(int index, SqlMapInfo value)
{
base.List.Insert(index, value);
}
public void Remove(SqlMapInfo value)
{
base.List.Remove(value);
}
public SqlMapInfo[] ToArray()
{
SqlMapInfo[] infoArray1 = new SqlMapInfo[base.Count];
this.CopyTo(infoArray1, 0);
return infoArray1;
}
public SqlMapInfo this[int index]
{
get
{
return (SqlMapInfo)base.List[index];
}
}
public SqlMapInfo this[string key]
{
get
{
for (int i = 0; i < this.Count; i++)
if (this[i].Name == key)
return this[i];
return null;
}
}
public class SqlMapCollectionEnumerator : IEnumerator
{
public SqlMapCollectionEnumerator(SqlMapCollection mappings)
{
this._temp = mappings;
this._enumerator = this._temp.GetEnumerator();
}
public bool MoveNext()
{
return this._enumerator.MoveNext();
}
public void Reset()
{
this._enumerator.Reset();
}
bool IEnumerator.MoveNext()
{
return this._enumerator.MoveNext();
}
void IEnumerator.Reset()
{
this._enumerator.Reset();
}
public SqlMapInfo Current
{
get
{
return (SqlMapInfo)this._enumerator.Current;
}
}
object IEnumerator.Current
{
get
{
return this._enumerator.Current;
}
}
private IEnumerator _enumerator;
private IEnumerable _temp;
}
}
}