2 // SoapAttributeOverrides.cs:
5 // John Donagher (john@webmeta.com)
7 // (C) 2002 John Donagher
11 using System.Collections;
\r
13 namespace System.Xml.Serialization
\r
18 public class SoapAttributeOverrides
\r
21 /// This class requires to store SoapAttrributes indexed by a key containg
\r
22 /// both Type and Member Name. There are 3 approaches to this IMO.
\r
23 /// 1. Make the key as "FullTypeName..MemberName", with ".." seperating Type and Member.
\r
24 /// 2. Use a jagged 2D hashtable. The main hashtable is indexed by Type and each value
\r
25 /// contains another hashtable which is indexed by member names. (Too many hashtables)
\r
26 /// 3. Use a new class which emcompasses the Type and MemberName. An implementation is there
\r
27 /// in TypeMember class in this namespace. (Too many instantiations of the class needed)
\r
29 /// Method 1 is the most elegent, but I am not sure if the seperator is language insensitive.
\r
30 /// What if someone writes a language which allows . in the member names.
\r
33 private Hashtable overrides;
\r
35 public SoapAttributeOverrides ()
\r
37 overrides = new Hashtable();
\r
40 public SoapAttributes this [Type type]
\r
42 get { return this [type, string.Empty]; }
\r
45 public SoapAttributes this [Type type, string member]
\r
49 return (SoapAttributes) overrides[GetKey(type,member)];
\r
53 public void Add (Type type, SoapAttributes attributes)
\r
55 Add(type, string.Empty, attributes);
\r
58 public void Add (Type type, string member, SoapAttributes attributes)
\r
60 if(overrides[GetKey(type, member)] != null)
\r
61 throw new Exception("The attributes for the given type and Member already exist in the collection");
\r
63 overrides.Add(GetKey(type,member), attributes);
\r
66 private TypeMember GetKey(Type type, string member)
\r
68 return new TypeMember(type, member);
\r