XmlReflectionImporter.cs 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550
  1. //
  2. // System.Xml.Serialization.XmlReflectionImporter
  3. //
  4. // Author:
  5. // Tim Coleman ([email protected])
  6. // Erik LeBel ([email protected])
  7. // Lluis Sanchez Gual ([email protected])
  8. //
  9. // Copyright (C) Tim Coleman, 2002
  10. // (C) 2003 Erik LeBel
  11. //
  12. using System.Reflection;
  13. using System.Collections;
  14. namespace System.Xml.Serialization {
  15. public class XmlReflectionImporter {
  16. string initialDefaultNamespace;
  17. XmlAttributeOverrides attributeOverrides;
  18. ArrayList includedTypes;
  19. Hashtable clrTypes = new Hashtable ();
  20. Hashtable schemaTypes = new Hashtable ();
  21. ReflectionHelper helper = new ReflectionHelper();
  22. int arrayChoiceCount = 1;
  23. #region Constructors
  24. public XmlReflectionImporter ()
  25. : this (null, null)
  26. {
  27. }
  28. public XmlReflectionImporter (string defaultNamespace)
  29. : this (null, defaultNamespace)
  30. {
  31. }
  32. public XmlReflectionImporter (XmlAttributeOverrides attributeOverrides)
  33. : this (attributeOverrides, null)
  34. {
  35. }
  36. public XmlReflectionImporter (XmlAttributeOverrides attributeOverrides, string defaultNamespace)
  37. {
  38. if (defaultNamespace == null)
  39. this.initialDefaultNamespace = String.Empty;
  40. else
  41. this.initialDefaultNamespace = defaultNamespace;
  42. if (attributeOverrides == null)
  43. this.attributeOverrides = new XmlAttributeOverrides();
  44. else
  45. this.attributeOverrides = attributeOverrides;
  46. }
  47. #endregion // Constructors
  48. #region Methods
  49. public XmlMembersMapping ImportMembersMapping (string elementName,
  50. string ns,
  51. XmlReflectionMember [] members,
  52. bool hasWrapperElement)
  53. {
  54. XmlMemberMapping[] mapping = new XmlMemberMapping[members.Length];
  55. for (int n=0; n<members.Length; n++)
  56. {
  57. XmlTypeMapMember mapMem = CreateMapMember (members[n], ns);
  58. mapping[n] = new XmlMemberMapping (members[n], mapMem);
  59. }
  60. XmlMembersMapping mps = new XmlMembersMapping (elementName, ns, hasWrapperElement, mapping);
  61. mps.Format = SerializationFormat.Literal;
  62. return mps;
  63. }
  64. public XmlTypeMapping ImportTypeMapping (Type type)
  65. {
  66. return ImportTypeMapping (type, null, null);
  67. }
  68. public XmlTypeMapping ImportTypeMapping (Type type, string defaultNamespace)
  69. {
  70. return ImportTypeMapping (type, null, defaultNamespace);
  71. }
  72. public XmlTypeMapping ImportTypeMapping (Type type, XmlRootAttribute group)
  73. {
  74. return ImportTypeMapping (type, group, null);
  75. }
  76. public XmlTypeMapping ImportTypeMapping (Type type, XmlRootAttribute root, string defaultNamespace)
  77. {
  78. if (type == null)
  79. throw new ArgumentNullException ("type");
  80. if (type == typeof (void))
  81. throw new InvalidOperationException ("Type " + type.Name + " may not be serialized.");
  82. if (defaultNamespace == null) defaultNamespace = initialDefaultNamespace;
  83. if (defaultNamespace == null) defaultNamespace = string.Empty;
  84. XmlTypeMapping map;
  85. switch (TypeTranslator.GetTypeData(type).SchemaType)
  86. {
  87. case SchemaTypes.Class: map = ImportClassMapping (type, root, defaultNamespace); break;
  88. case SchemaTypes.Array: map = ImportListMapping (type, root, defaultNamespace, null, 0); break;
  89. case SchemaTypes.XmlNode: map = ImportXmlNodeMapping (type, root, defaultNamespace); break;
  90. case SchemaTypes.Primitive: map = ImportPrimitiveMapping (type, root, defaultNamespace); break;
  91. case SchemaTypes.Enum: map = ImportEnumMapping (type, root, defaultNamespace); break;
  92. case SchemaTypes.DataSet:
  93. default: throw new NotSupportedException ("Type " + type.FullName + " not supported for XML stialization");
  94. }
  95. map.Format = SerializationFormat.Literal;
  96. return map;
  97. }
  98. XmlTypeMapping CreateTypeMapping (TypeData typeData, XmlRootAttribute root, string defaultXmlType, string defaultNamespace)
  99. {
  100. string membersNamespace = defaultNamespace;
  101. string elementName;
  102. XmlAttributes atts = null;
  103. if (defaultXmlType == null) defaultXmlType = typeData.XmlType;
  104. if (!typeData.IsListType)
  105. {
  106. if (attributeOverrides != null)
  107. atts = attributeOverrides[typeData.Type];
  108. }
  109. if (atts == null)
  110. atts = new XmlAttributes (typeData.Type);
  111. if (atts.XmlRoot != null && root == null)
  112. root = atts.XmlRoot;
  113. if (atts.XmlType != null)
  114. {
  115. if (atts.XmlType.Namespace != null && atts.XmlType.Namespace != string.Empty)
  116. membersNamespace = atts.XmlType.Namespace;
  117. if (atts.XmlType.TypeName != null && atts.XmlType.TypeName != string.Empty)
  118. defaultXmlType = atts.XmlType.TypeName;
  119. }
  120. elementName = defaultXmlType;
  121. if (root != null)
  122. {
  123. if (root.ElementName != null && root.ElementName != String.Empty)
  124. elementName = root.ElementName;
  125. if (root.Namespace != null && root.Namespace != String.Empty)
  126. membersNamespace = root.Namespace;
  127. }
  128. if (membersNamespace == null) membersNamespace = "";
  129. XmlTypeMapping map = new XmlTypeMapping (elementName, membersNamespace, typeData, defaultXmlType);
  130. return map;
  131. }
  132. XmlTypeMapping ImportClassMapping (Type type, XmlRootAttribute root, string defaultNamespace)
  133. {
  134. TypeData typeData = TypeTranslator.GetTypeData (type);
  135. XmlTypeMapping map = helper.GetRegisteredClrType (type, defaultNamespace);
  136. if (map != null) return map;
  137. map = CreateTypeMapping (typeData, root, null, defaultNamespace);
  138. helper.RegisterClrType (map, type, defaultNamespace);
  139. helper.RegisterSchemaType (map, map.XmlType, defaultNamespace);
  140. ClassMap classMap = new ClassMap ();
  141. map.ObjectMap = classMap;
  142. // Import members
  143. try
  144. {
  145. ICollection members = GetReflectionMembers (type);
  146. foreach (XmlReflectionMember rmember in members)
  147. {
  148. if (rmember.XmlAttributes.XmlIgnore) continue;
  149. classMap.AddMember (CreateMapMember (rmember, map.Namespace));
  150. }
  151. }
  152. catch (Exception ex) {
  153. throw helper.CreateError (map, ex.Message);
  154. }
  155. // Import derived classes
  156. XmlIncludeAttribute[] includes = (XmlIncludeAttribute[])type.GetCustomAttributes (typeof (XmlIncludeAttribute), false);
  157. for (int n=0; n<includes.Length; n++)
  158. {
  159. Type includedType = includes[n].Type;
  160. if (!includedType.IsSubclassOf(type)) throw helper.CreateError (map, "Type '" + includedType.FullName + "' is not a subclass of '" + type.FullName + "'");
  161. map.DerivedTypes.Add (ImportTypeMapping (includedType, root, defaultNamespace));
  162. }
  163. if (type == typeof (object) && includedTypes != null)
  164. {
  165. foreach (Type intype in includedTypes)
  166. map.DerivedTypes.Add (ImportTypeMapping (intype, defaultNamespace));
  167. }
  168. // Register this map as a derived class of object
  169. if (typeData.Type != typeof(object))
  170. ImportTypeMapping (typeof(object)).DerivedTypes.Add (map);
  171. return map;
  172. }
  173. XmlTypeMapping ImportListMapping (Type type, XmlRootAttribute root, string defaultNamespace, XmlAttributes atts, int nestingLevel)
  174. {
  175. TypeData typeData = TypeTranslator.GetTypeData (type);
  176. ListMap obmap = new ListMap ();
  177. if (atts == null) atts = new XmlAttributes();
  178. Type itemType = typeData.ListItemType;
  179. // warning: byte[][] should not be considered multiarray
  180. bool isMultiArray = (type.IsArray && (TypeTranslator.GetTypeData(itemType).SchemaType == SchemaTypes.Array) && itemType.IsArray);
  181. XmlTypeMapElementInfoList list = new XmlTypeMapElementInfoList();
  182. foreach (XmlArrayItemAttribute att in atts.XmlArrayItems)
  183. {
  184. if (att.NestingLevel != nestingLevel) continue;
  185. Type elemType = (att.Type != null) ? att.Type : itemType;
  186. XmlTypeMapElementInfo elem = new XmlTypeMapElementInfo (null, TypeTranslator.GetTypeData(elemType));
  187. elem.DataType = att.DataType;
  188. elem.Namespace = att.Namespace != null ? att.Namespace : "";
  189. elem.Form = att.Form;
  190. elem.IsNullable = att.IsNullable;
  191. elem.NestingLevel = att.NestingLevel;
  192. if (isMultiArray)
  193. elem.MappedType = ImportListMapping (elemType, null, elem.Namespace, atts, nestingLevel + 1);
  194. else if (elem.TypeData.IsComplexType)
  195. elem.MappedType = ImportTypeMapping (elemType, null, elem.Namespace);
  196. if (att.ElementName != null) elem.ElementName = att.ElementName;
  197. else if (elem.MappedType != null) elem.ElementName = elem.MappedType.ElementName;
  198. else elem.ElementName = TypeTranslator.GetTypeData(elemType).XmlType;
  199. list.Add (elem);
  200. }
  201. if (list.Count == 0)
  202. {
  203. XmlTypeMapElementInfo elem = new XmlTypeMapElementInfo (null, TypeTranslator.GetTypeData (itemType));
  204. if (isMultiArray)
  205. elem.MappedType = ImportListMapping (itemType, null, defaultNamespace, atts, nestingLevel + 1);
  206. else if (elem.TypeData.IsComplexType)
  207. elem.MappedType = ImportTypeMapping (itemType, null, defaultNamespace);
  208. if (elem.MappedType != null) elem.ElementName = elem.MappedType.ElementName;
  209. else elem.ElementName = TypeTranslator.GetTypeData(itemType).XmlType ;
  210. elem.Namespace = (defaultNamespace != null) ? defaultNamespace : "";
  211. elem.IsNullable = true; // By default, items are nullable
  212. list.Add (elem);
  213. }
  214. obmap.ItemInfo = list;
  215. // If there can be different element names (types) in the array, then its name cannot
  216. // be "ArrayOfXXX" it must be something like ArrayOfChoiceNNN
  217. string baseName;
  218. if (list.Count > 1)
  219. baseName = "ArrayOfChoice" + (arrayChoiceCount++);
  220. else
  221. {
  222. XmlTypeMapElementInfo elem = ((XmlTypeMapElementInfo)list[0]);
  223. if (elem.MappedType != null) baseName = GetArrayName (elem.MappedType.ElementName);
  224. else baseName = GetArrayName (elem.ElementName);
  225. }
  226. // Avoid name colisions
  227. int nameCount = 1;
  228. string name = baseName;
  229. do {
  230. XmlTypeMapping foundMap = helper.GetRegisteredSchemaType (name, defaultNamespace);
  231. if (foundMap == null) nameCount = -1;
  232. else if (obmap.Equals (foundMap.ObjectMap)) return foundMap;
  233. else name = baseName + (nameCount++);
  234. }
  235. while (nameCount != -1);
  236. XmlTypeMapping map = CreateTypeMapping (typeData, root, name, defaultNamespace);
  237. map.ObjectMap = obmap;
  238. // Register this map as a derived class of object
  239. helper.RegisterSchemaType (map, name, defaultNamespace);
  240. ImportTypeMapping (typeof(object)).DerivedTypes.Add (map);
  241. return map;
  242. }
  243. string GetArrayName (string elemName)
  244. {
  245. return "ArrayOf" + Char.ToUpper (elemName [0]) + elemName.Substring (1);
  246. }
  247. XmlTypeMapping ImportXmlNodeMapping (Type type, XmlRootAttribute root, string defaultNamespace)
  248. {
  249. XmlTypeMapping map = helper.GetRegisteredClrType (type, defaultNamespace);
  250. if (map != null) return map;
  251. // Registers the maps for XmlNode and XmlElement
  252. XmlTypeMapping nodeMap = CreateTypeMapping (TypeTranslator.GetTypeData (typeof(XmlNode)), root, null, defaultNamespace);
  253. helper.RegisterClrType (nodeMap, typeof(XmlNode), defaultNamespace);
  254. XmlTypeMapping elemMap = CreateTypeMapping (TypeTranslator.GetTypeData (typeof(XmlElement)), root, null, defaultNamespace);
  255. helper.RegisterClrType (elemMap, typeof(XmlElement), defaultNamespace);
  256. ImportTypeMapping (typeof(object)).DerivedTypes.Add (nodeMap);
  257. ImportTypeMapping (typeof(object)).DerivedTypes.Add (elemMap);
  258. nodeMap.DerivedTypes.Add (elemMap);
  259. return helper.GetRegisteredClrType (type, defaultNamespace);
  260. }
  261. XmlTypeMapping ImportPrimitiveMapping (Type type, XmlRootAttribute root, string defaultNamespace)
  262. {
  263. XmlTypeMapping map = helper.GetRegisteredClrType (type, defaultNamespace);
  264. if (map != null) return map;
  265. map = CreateTypeMapping (TypeTranslator.GetTypeData (type), root, null, defaultNamespace);
  266. helper.RegisterClrType (map, type, defaultNamespace);
  267. return map;
  268. }
  269. XmlTypeMapping ImportEnumMapping (Type type, XmlRootAttribute root, string defaultNamespace)
  270. {
  271. XmlTypeMapping map = helper.GetRegisteredClrType (type, defaultNamespace);
  272. if (map != null) return map;
  273. map = CreateTypeMapping (TypeTranslator.GetTypeData (type), root, null, defaultNamespace);
  274. helper.RegisterClrType (map, type, defaultNamespace);
  275. string [] names = Enum.GetNames (type);
  276. EnumMap.EnumMapMember[] members = new EnumMap.EnumMapMember[names.Length];
  277. for (int n=0; n<names.Length; n++)
  278. {
  279. MemberInfo[] mem = type.GetMember (names[n]);
  280. string xmlName = names[n];
  281. object[] atts = mem[0].GetCustomAttributes (typeof(XmlEnumAttribute), false);
  282. if (atts.Length > 0) xmlName = ((XmlEnumAttribute)atts[0]).Name;
  283. members[n] = new EnumMap.EnumMapMember (xmlName, names[n]);
  284. }
  285. map.ObjectMap = new EnumMap (members);
  286. ImportTypeMapping (typeof(object)).DerivedTypes.Add (map);
  287. return map;
  288. }
  289. public ICollection GetReflectionMembers (Type type)
  290. {
  291. ArrayList members = new ArrayList();
  292. PropertyInfo[] properties = type.GetProperties (BindingFlags.Instance | BindingFlags.Public);
  293. foreach (PropertyInfo prop in properties)
  294. {
  295. if (!prop.CanRead) continue;
  296. XmlAttributes atts = attributeOverrides[type, prop.Name];
  297. if (atts == null) atts = new XmlAttributes (prop);
  298. if (atts.XmlIgnore) continue;
  299. XmlReflectionMember member = new XmlReflectionMember(prop.Name, prop.PropertyType, atts);
  300. members.Add (member);
  301. }
  302. FieldInfo[] fields = type.GetFields (BindingFlags.Instance | BindingFlags.Public);
  303. foreach (FieldInfo field in fields)
  304. {
  305. XmlAttributes atts = attributeOverrides[type, field.Name];
  306. if (atts == null) atts = new XmlAttributes (field);
  307. if (atts.XmlIgnore) continue;
  308. XmlReflectionMember member = new XmlReflectionMember(field.Name, field.FieldType, atts);
  309. members.Add (member);
  310. }
  311. return members;
  312. }
  313. private XmlTypeMapMember CreateMapMember (XmlReflectionMember rmember, string defaultNamespace)
  314. {
  315. XmlTypeMapMember mapMember;
  316. XmlAttributes atts = rmember.XmlAttributes;
  317. TypeData typeData = TypeTranslator.GetTypeData (rmember.MemberType);
  318. if (atts.XmlAnyAttribute != null)
  319. {
  320. if ( (rmember.MemberType.FullName == "System.Xml.XmlAttribute[]") ||
  321. (rmember.MemberType.FullName == "System.Xml.XmlNode[]") )
  322. {
  323. mapMember = new XmlTypeMapMemberAnyAttribute();
  324. }
  325. else
  326. throw new InvalidOperationException ("XmlAnyAttributeAttribute can only be applied to members of type XmlAttribute[] or XmlNode[]");
  327. }
  328. else if (atts.XmlAnyElements != null && atts.XmlAnyElements.Count > 0)
  329. {
  330. if ( (rmember.MemberType.FullName == "System.Xml.XmlElement[]") ||
  331. (rmember.MemberType.FullName == "System.Xml.XmlNode[]") ||
  332. (rmember.MemberType.FullName == "System.Xml.XmlElement"))
  333. {
  334. XmlTypeMapMemberAnyElement member = new XmlTypeMapMemberAnyElement();
  335. member.ElementInfo = ImportAnyElementInfo (defaultNamespace, member, atts);
  336. mapMember = member;
  337. }
  338. else
  339. throw new InvalidOperationException ("XmlAnyElementAttribute can only be applied to members of type XmlElement, XmlElement[] or XmlNode[]");
  340. }
  341. else if (atts.XmlAttribute != null)
  342. {
  343. // An attribute
  344. if (atts.XmlElements != null && atts.XmlElements.Count > 0)
  345. throw new Exception ("XmlAttributeAttribute and XmlElementAttribute cannot be applied to the same member");
  346. XmlTypeMapMemberAttribute mapAttribute = new XmlTypeMapMemberAttribute ();
  347. if (atts.XmlAttribute.AttributeName == null)
  348. mapAttribute.AttributeName = rmember.MemberName;
  349. else
  350. mapAttribute.AttributeName = atts.XmlAttribute.AttributeName;
  351. mapAttribute.DataType = atts.XmlAttribute.DataType;
  352. mapAttribute.Form = atts.XmlAttribute.Form;
  353. mapAttribute.Namespace = (atts.XmlAttribute.Namespace != null) ? atts.XmlAttribute.Namespace : "";
  354. if (typeData.IsComplexType)
  355. mapAttribute.MappedType = ImportTypeMapping (typeData.Type, null, mapAttribute.Namespace);
  356. mapMember = mapAttribute;
  357. }
  358. else if (typeData.SchemaType == SchemaTypes.Array)
  359. {
  360. if (atts.XmlElements.Count > 0)
  361. {
  362. // A flat list
  363. // TODO: check that it does not have XmlArrayAttribute
  364. XmlTypeMapMemberFlatList member = new XmlTypeMapMemberFlatList ();
  365. member.ListMap = new ListMap ();
  366. member.ListMap.ItemInfo = ImportElementInfo (rmember.MemberName, defaultNamespace, typeData.ListItemType, member, atts);
  367. member.ElementInfo = member.ListMap.ItemInfo;
  368. mapMember = member;
  369. }
  370. else
  371. {
  372. // A list
  373. XmlTypeMapMemberList member = new XmlTypeMapMemberList ();
  374. // Creates an ElementInfo that identifies the array instance.
  375. member.ElementInfo = new XmlTypeMapElementInfoList();
  376. XmlTypeMapElementInfo elem = new XmlTypeMapElementInfo (member, typeData);
  377. elem.ElementName = (atts.XmlArray != null && atts.XmlArray.ElementName != null) ? atts.XmlArray.ElementName : rmember.MemberName;
  378. elem.Namespace = (atts.XmlArray != null && atts.XmlArray.Namespace != null) ? atts.XmlArray.Namespace : defaultNamespace;
  379. elem.MappedType = ImportListMapping (rmember.MemberType, null, elem.Namespace, atts, 0);
  380. member.ElementInfo.Add (elem);
  381. mapMember = member;
  382. }
  383. }
  384. else
  385. {
  386. // An element
  387. XmlTypeMapMemberElement member = new XmlTypeMapMemberElement ();
  388. member.ElementInfo = ImportElementInfo (rmember.MemberName, defaultNamespace, rmember.MemberType, member, atts);
  389. mapMember = member;
  390. }
  391. mapMember.TypeData = typeData;
  392. mapMember.Name = rmember.MemberName;
  393. return mapMember;
  394. }
  395. XmlTypeMapElementInfoList ImportElementInfo (string defaultName, string defaultNamespace, Type defaultType, XmlTypeMapMemberElement member, XmlAttributes atts)
  396. {
  397. XmlTypeMapElementInfoList list = new XmlTypeMapElementInfoList();
  398. if (atts.XmlElements.Count == 0)
  399. {
  400. XmlTypeMapElementInfo elem = new XmlTypeMapElementInfo (member, TypeTranslator.GetTypeData(defaultType));
  401. elem.ElementName = defaultName;
  402. elem.Namespace = defaultNamespace;
  403. if (elem.TypeData.IsComplexType)
  404. elem.MappedType = ImportTypeMapping (defaultType, null, defaultNamespace);
  405. list.Add (elem);
  406. }
  407. bool multiType = (atts.XmlElements.Count > 1);
  408. foreach (XmlElementAttribute att in atts.XmlElements)
  409. {
  410. Type elemType = (att.Type != null) ? att.Type : defaultType;
  411. XmlTypeMapElementInfo elem = new XmlTypeMapElementInfo (member, TypeTranslator.GetTypeData(elemType));
  412. elem.ElementName = (att.ElementName != null) ? att.ElementName : defaultName;
  413. elem.DataType = att.DataType;
  414. elem.Namespace = (att.Namespace != null) ? att.Namespace : defaultNamespace;
  415. elem.Form = att.Form;
  416. elem.IsNullable = att.IsNullable;
  417. if (elem.TypeData.IsComplexType)
  418. elem.MappedType = ImportTypeMapping (elemType, null, elem.Namespace);
  419. if (att.ElementName != null)
  420. elem.ElementName = att.ElementName;
  421. else if (multiType) {
  422. if (elem.MappedType != null) elem.ElementName = elem.MappedType.ElementName;
  423. else elem.ElementName = TypeTranslator.GetTypeData(elemType).XmlType;
  424. }
  425. else
  426. elem.ElementName = defaultName;
  427. list.Add (elem);
  428. }
  429. return list;
  430. }
  431. XmlTypeMapElementInfoList ImportAnyElementInfo (string defaultNamespace, XmlTypeMapMemberElement member, XmlAttributes atts)
  432. {
  433. XmlTypeMapElementInfoList list = new XmlTypeMapElementInfoList();
  434. foreach (XmlAnyElementAttribute att in atts.XmlAnyElements)
  435. {
  436. XmlTypeMapElementInfo elem = new XmlTypeMapElementInfo (member, TypeTranslator.GetTypeData(typeof(XmlElement)));
  437. elem.ElementName = (att.Name != null) ? att.Name : "";
  438. elem.Namespace = (att.Namespace != null) ? att.Namespace : "";
  439. list.Add (elem);
  440. }
  441. return list;
  442. }
  443. public void IncludeType (Type type)
  444. {
  445. if (type == null)
  446. throw new ArgumentNullException ("type");
  447. if (includedTypes == null) includedTypes = new ArrayList ();
  448. includedTypes.Add (type);
  449. }
  450. #endregion // Methods
  451. }
  452. }