|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
|
|
|
|
namespace HuizhongLibrary.Common.Configuration
|
|
|
|
|
{
|
|
|
|
|
public class Config
|
|
|
|
|
{
|
|
|
|
|
private string m_Key;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 键
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string Key
|
|
|
|
|
{
|
|
|
|
|
get { return m_Key; }
|
|
|
|
|
set { m_Key = value; }
|
|
|
|
|
}
|
|
|
|
|
private string m_Value;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 值
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string Value
|
|
|
|
|
{
|
|
|
|
|
get { return m_Value; }
|
|
|
|
|
set { m_Value = value; }
|
|
|
|
|
}
|
|
|
|
|
private string m_Namespace;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 命名空间
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string Namespace
|
|
|
|
|
{
|
|
|
|
|
get { return m_Namespace; }
|
|
|
|
|
set { m_Namespace = value; }
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class ConfigCollection:IList<Config>
|
|
|
|
|
{
|
|
|
|
|
public List<Config> items = new List<Config>();
|
|
|
|
|
|
|
|
|
|
#region IList<Config> 成员
|
|
|
|
|
|
|
|
|
|
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<Config> 成员
|
|
|
|
|
|
|
|
|
|
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<Config> 成员
|
|
|
|
|
|
|
|
|
|
public IEnumerator<Config> GetEnumerator()
|
|
|
|
|
{
|
|
|
|
|
return items.GetEnumerator();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region IEnumerable 成员
|
|
|
|
|
|
|
|
|
|
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
|
|
|
|
|
{
|
|
|
|
|
return items.GetEnumerator();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|