2 // XmlAttributeOverrides.cs:
5 // John Donagher (john@webmeta.com)
7 // (C) 2002 John Donagher
11 using System.Collections;
12 using System.Globalization;
14 namespace System.Xml.Serialization
17 /// Summary description for XmlAttributeOverrides.
19 public class XmlAttributeOverrides
22 private Hashtable overrides;
24 public XmlAttributeOverrides ()
26 overrides = new Hashtable();
29 public XmlAttributes this [Type type]
31 get { return this [type, string.Empty]; }
34 public XmlAttributes this [Type type, string member]
38 return (XmlAttributes) overrides[GetKey(type,member)];
42 public void Add (Type type, XmlAttributes attributes)
44 Add(type, string.Empty, attributes);
47 public void Add (Type type, string member, XmlAttributes attributes)
49 if(overrides[GetKey(type, member)] != null)
50 throw new Exception("The attributes for the given type and Member already exist in the collection");
52 overrides.Add(GetKey(type,member), attributes);
55 private TypeMember GetKey(Type type, string member)
57 return new TypeMember(type, member);
60 internal void AddKeyHash (System.Text.StringBuilder sb)
63 foreach (DictionaryEntry entry in overrides)
65 XmlAttributes val = (XmlAttributes) entry.Value;
66 IFormattable keyFormattable = entry.Key as IFormattable;
67 sb.Append (keyFormattable != null ? keyFormattable.ToString (null, CultureInfo.InvariantCulture) : entry.Key.ToString()).Append(' ');