using System;
using System.Collections.Generic;
using System.Text;
namespace HuizhongLibrary.Common.Configuration
{
public class Config
{
private string m_Key;
///
/// 键
///
public string Key
{
get { return m_Key; }
set { m_Key = value; }
}
private string m_Value;
///
/// 值
///
public string Value
{
get { return m_Value; }
set { m_Value = value; }
}
private string m_Namespace;
///
/// 命名空间
///
public string Namespace
{
get { return m_Namespace; }
set { m_Namespace = value; }
}
}
public class ConfigCollection:IList
{
public List items = new List();
#region IList 成员
public int IndexOf(Config item)
{
return items.IndexOf(item);
}
public void Insert(int index, Config item)
{
items.Insert(index, item);
}
public void RemoveAt(int index)
{
items.RemoveAt(index);
}
public Config this[int index]
{
get
{
return items[index];
}
set
{
items[index]=value;
}
}
public Config this[string key]
{
get
{
foreach (Config cf in this.items)
{
if (cf.Key == key) return cf;
}
return null;
}
}
public string getValue(string key)
{
foreach (Config cf in this.items)
{
if (cf.Key == key) return cf.Value;
}
return "";
}
public string getNameSpace(string key)
{
foreach (Config cf in this.items)
{
if (cf.Key == key) return cf.Namespace;
}
return "";
}
public bool ContainsKey(string key)
{
foreach (Config cf in this.items)
{
if (cf.Key == key) return true;
}
return false;
}
#endregion
#region ICollection 成员
public void Add(Config item)
{
items.Add(item);
}
public void Clear()
{
items.Clear();
}
public bool Contains(Config item)
{
return items.Contains(item);
}
public void CopyTo(Config[] array, int arrayIndex)
{
items.CopyTo(array, arrayIndex);
}
public int Count
{
get { return items.Count; }
}
public bool IsReadOnly
{
get { return true; }
}
public bool Remove(Config item)
{
return items.Remove(item);
}
#endregion
#region IEnumerable 成员
public IEnumerator GetEnumerator()
{
return items.GetEnumerator();
}
#endregion
#region IEnumerable 成员
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
{
return items.GetEnumerator();
}
#endregion
}
}