From MSDN at XmlSerializer:
http://msdn.microsoft.com/library/de...classtopic.asp
I implemented the indexable property and the add function but I'm still
getting the following exception:"The type System.Collections.Hashtable
is not supported because it implements IDictionary."
My code for Item and Add add-on looks like this:
Expand|Select|Wrap|Line Numbers
- [Serializable]
- public class DaysArchive
- {
- public class HashTableItems
- {
- private IDictionaryEnumerator HashEntries;
- public HashTableItems()
- {
- }
- public void Initialize(Hashtable table)
- {
- HashEntries = table.GetEnumerator();
- }
- public System.Collections.DictionaryEntry this[string key]
- {
- get
- {
- HashEntries.Reset();
- HashEntries.MoveNext();
- while ((string)HashEntries.Key != key)
- {
- HashEntries.MoveNext();
- }
- return new DictionaryEntry(HashEntries.Key,HashEntries.Value);
- }
- }
- }
- public readonly HashTableItems Item;
- public Hashtable archive;
- public DaysArchive()
- {
- archive = new Hashtable();
- this.Item = new HashTableItems();
- this.Item.Initialize(archive);
- }
- public void AddItem(string Name, bool offline)
- {
- if (archive.ContainsKey(Name) == false)
- archive.Add(Name,offline);
- }
- public bool GetKeyValue(string Name)
- {
- if (archive.ContainsKey(Name) == false)
- throw new Exception("Key could not be found!");
- IDictionaryEnumerator days_enum = archive.GetEnumerator();
- days_enum.MoveNext();
- while (((string)days_enum.Key != Name)&&(days_enum.MoveNext()));
- return (bool)days_enum.Value;
- }
- public bool IsKeyInCollection(string Name)
- {
- return archive.ContainsKey(Name);
- }
- public void Add(System.Collections.DictionaryEntry cel)
- {
- archive.Add(cel.Key,cel.Value);
- }
- }