public class SimpleNameValueCollection
{
private Hashtable m_entriesTable;
public SimpleNameValueCollection()
{
m_entriesTable = new Hashtable();
}
public void Add(string key, string value)
{
ArrayList entriesArray = new ArrayList();
if (m_entriesTable[key] == null)
{
entriesArray.Add(value);
m_entriesTable.Add(key, entriesArray);
}
ArrayList bakArray = (ArrayList)m_entriesTable[key];
bakArray.Add(value);
}
public string[] GetValues(string name)
{
ArrayList bakArray = (ArrayList)m_entriesTable[name];
return GetAsStringArray(bakArray);
}
private static string[] GetAsStringArray(ArrayList list)
{
int count = (list != null) ? list.Count : 0;
if (count == 0)
{
return null;
}
string[] array = new string[count];
list.CopyTo(0, array, 0, count);
return array;
}
}