SoapSchemaExporterTests.cs 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480
  1. //
  2. // System.Xml.Serialization.SoapSchemaExporterTests
  3. //
  4. // Author:
  5. // Gert Driesen ([email protected])
  6. //
  7. // (C) 2005 Novell
  8. //
  9. using System;
  10. using System.Collections;
  11. using System.Globalization;
  12. using System.IO;
  13. using System.Xml;
  14. using System.Xml.Schema;
  15. using System.Xml.Serialization;
  16. using NUnit.Framework;
  17. using MonoTests.System.Xml.TestClasses;
  18. namespace MonoTests.System.XmlSerialization
  19. {
  20. [TestFixture]
  21. public class SoapSchemaExporterTests
  22. {
  23. [Test]
  24. [Category ("NotWorking")]
  25. public void ExportStruct ()
  26. {
  27. SoapReflectionImporter ri = new SoapReflectionImporter ("NSTimeSpan");
  28. XmlSchemas schemas = new XmlSchemas ();
  29. SoapSchemaExporter sx = new SoapSchemaExporter (schemas);
  30. XmlTypeMapping tm = ri.ImportTypeMapping (typeof (TimeSpan));
  31. sx.ExportTypeMapping (tm);
  32. Assert.AreEqual (1, schemas.Count, "#1");
  33. StringWriter sw = new StringWriter ();
  34. schemas[0].Write (sw);
  35. Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
  36. "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
  37. #if NET_2_0
  38. "<xs:schema xmlns:tns=\"NSTimeSpan\" elementFormDefault=\"qualified\" targetNamespace=\"NSTimeSpan\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
  39. #else
  40. "<xs:schema xmlns:tns=\"NSTimeSpan\" targetNamespace=\"NSTimeSpan\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
  41. #endif
  42. " <xs:complexType name=\"TimeSpan\" />{0}" +
  43. "</xs:schema>", Environment.NewLine), sw.ToString (), "#2");
  44. }
  45. [Test]
  46. [Category ("NotWorking")]
  47. public void ExportClass ()
  48. {
  49. SoapAttributeOverrides overrides = new SoapAttributeOverrides ();
  50. SoapAttributes attr = new SoapAttributes ();
  51. SoapElementAttribute element = new SoapElementAttribute ();
  52. element.ElementName = "saying";
  53. element.IsNullable = true;
  54. attr.SoapElement = element;
  55. overrides.Add (typeof (SimpleClass), "something", attr);
  56. SoapReflectionImporter ri = new SoapReflectionImporter (overrides, "NSSimpleClass");
  57. XmlSchemas schemas = new XmlSchemas ();
  58. SoapSchemaExporter sx = new SoapSchemaExporter (schemas);
  59. XmlTypeMapping tm = ri.ImportTypeMapping (typeof (SimpleClass));
  60. sx.ExportTypeMapping (tm);
  61. Assert.AreEqual (1, schemas.Count, "#1");
  62. StringWriter sw = new StringWriter ();
  63. schemas[0].Write (sw);
  64. Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
  65. "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
  66. #if NET_2_0
  67. "<xs:schema xmlns:tns=\"NSSimpleClass\" elementFormDefault=\"qualified\" targetNamespace=\"NSSimpleClass\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
  68. #else
  69. "<xs:schema xmlns:tns=\"NSSimpleClass\" targetNamespace=\"NSSimpleClass\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
  70. #endif
  71. " <xs:complexType name=\"SimpleClass\">{0}" +
  72. " <xs:sequence>{0}" +
  73. #if NET_2_0
  74. " <xs:element minOccurs=\"0\" maxOccurs=\"1\" form=\"unqualified\" name=\"saying\" nillable=\"true\" type=\"xs:string\" />{0}" +
  75. #else
  76. " <xs:element minOccurs=\"1\" maxOccurs=\"1\" name=\"saying\" type=\"xs:string\" />{0}" +
  77. #endif
  78. " </xs:sequence>{0}" +
  79. " </xs:complexType>{0}" +
  80. "</xs:schema>", Environment.NewLine), sw.ToString (), "#2");
  81. }
  82. [Test]
  83. [Category ("NotWorking")]
  84. [ExpectedException (typeof (InvalidOperationException))] // Cannot use wildcards at the top level of a schema.
  85. public void ExportClass_XmlNode ()
  86. {
  87. XmlReflectionImporter ri = new XmlReflectionImporter ("NS1");
  88. XmlSchemas schemas = new XmlSchemas ();
  89. XmlSchemaExporter sx = new XmlSchemaExporter (schemas);
  90. XmlTypeMapping tm = ri.ImportTypeMapping (typeof (XmlNode));
  91. sx.ExportTypeMapping (tm);
  92. }
  93. [Test]
  94. [Category ("NotWorking")]
  95. [ExpectedException (typeof (InvalidOperationException))] // Cannot use wildcards at the top level of a schema.
  96. public void ExportClass_XmlElement ()
  97. {
  98. XmlReflectionImporter ri = new XmlReflectionImporter ("NS1");
  99. XmlSchemas schemas = new XmlSchemas ();
  100. XmlSchemaExporter sx = new XmlSchemaExporter (schemas);
  101. XmlTypeMapping tm = ri.ImportTypeMapping (typeof (XmlElement));
  102. sx.ExportTypeMapping (tm);
  103. }
  104. [Test]
  105. [Category ("NotWorking")]
  106. public void ExportClass_Array ()
  107. {
  108. SoapAttributeOverrides overrides = new SoapAttributeOverrides ();
  109. SoapAttributes attr = new SoapAttributes ();
  110. SoapElementAttribute element = new SoapElementAttribute ();
  111. element.ElementName = "saying";
  112. element.IsNullable = true;
  113. attr.SoapElement = element;
  114. overrides.Add (typeof (SimpleClass), "something", attr);
  115. SoapReflectionImporter ri = new SoapReflectionImporter (overrides, "NSSimpleClassArray");
  116. XmlSchemas schemas = new XmlSchemas ();
  117. SoapSchemaExporter sx = new SoapSchemaExporter (schemas);
  118. XmlTypeMapping tm = ri.ImportTypeMapping (typeof (SimpleClass[]));
  119. sx.ExportTypeMapping (tm);
  120. Assert.AreEqual (1, schemas.Count, "#1");
  121. StringWriter sw = new StringWriter ();
  122. schemas[0].Write (sw);
  123. Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
  124. "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
  125. #if NET_2_0
  126. "<xs:schema xmlns:tns=\"NSSimpleClassArray\" elementFormDefault=\"qualified\" targetNamespace=\"NSSimpleClassArray\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
  127. #else
  128. "<xs:schema xmlns:tns=\"NSSimpleClassArray\" targetNamespace=\"NSSimpleClassArray\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
  129. #endif
  130. " <xs:import namespace=\"http://schemas.xmlsoap.org/soap/encoding/\" />{0}" +
  131. " <xs:import namespace=\"http://schemas.xmlsoap.org/wsdl/\" />{0}" +
  132. " <xs:complexType name=\"ArrayOfSimpleClass\">{0}" +
  133. " <xs:complexContent mixed=\"false\">{0}" +
  134. " <xs:restriction xmlns:q1=\"http://schemas.xmlsoap.org/soap/encoding/\" base=\"q1:Array\">{0}" +
  135. " <xs:attribute d5p1:arrayType=\"tns:SimpleClass[]\" ref=\"q1:arrayType\" xmlns:d5p1=\"http://schemas.xmlsoap.org/wsdl/\" />{0}" +
  136. " </xs:restriction>{0}" +
  137. " </xs:complexContent>{0}" +
  138. " </xs:complexType>{0}" +
  139. " <xs:complexType name=\"SimpleClass\">{0}" +
  140. " <xs:sequence>{0}" +
  141. #if NET_2_0
  142. " <xs:element minOccurs=\"0\" maxOccurs=\"1\" form=\"unqualified\" name=\"saying\" nillable=\"true\" type=\"xs:string\" />{0}" +
  143. #else
  144. " <xs:element minOccurs=\"1\" maxOccurs=\"1\" name=\"saying\" type=\"xs:string\" />{0}" +
  145. #endif
  146. " </xs:sequence>{0}" +
  147. " </xs:complexType>{0}" +
  148. "</xs:schema>", Environment.NewLine), sw.ToString (), "#2");
  149. }
  150. [Test]
  151. [Category ("NotWorking")]
  152. public void ExportEnum ()
  153. {
  154. SoapReflectionImporter ri = new SoapReflectionImporter ("NSEnumDefaultValue");
  155. XmlSchemas schemas = new XmlSchemas ();
  156. SoapSchemaExporter sx = new SoapSchemaExporter (schemas);
  157. XmlTypeMapping tm = ri.ImportTypeMapping (typeof (EnumDefaultValue));
  158. sx.ExportTypeMapping (tm);
  159. Assert.AreEqual (1, schemas.Count, "#1");
  160. StringWriter sw = new StringWriter ();
  161. schemas[0].Write (sw);
  162. Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
  163. "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
  164. #if NET_2_0
  165. "<xs:schema xmlns:tns=\"NSEnumDefaultValue\" elementFormDefault=\"qualified\" targetNamespace=\"NSEnumDefaultValue\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
  166. #else
  167. "<xs:schema xmlns:tns=\"NSEnumDefaultValue\" targetNamespace=\"NSEnumDefaultValue\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
  168. #endif
  169. " <xs:simpleType name=\"EnumDefaultValue\">{0}" +
  170. " <xs:list>{0}" +
  171. " <xs:simpleType>{0}" +
  172. " <xs:restriction base=\"xs:string\">{0}" +
  173. " <xs:enumeration value=\"e1\" />{0}" +
  174. " <xs:enumeration value=\"e2\" />{0}" +
  175. " <xs:enumeration value=\"e3\" />{0}" +
  176. " </xs:restriction>{0}" +
  177. " </xs:simpleType>{0}" +
  178. " </xs:list>{0}" +
  179. " </xs:simpleType>{0}" +
  180. "</xs:schema>", Environment.NewLine), sw.ToString (), "#2");
  181. ri = new SoapReflectionImporter ("NSEnumDefaultValueNF");
  182. schemas = new XmlSchemas ();
  183. sx = new SoapSchemaExporter (schemas);
  184. tm = ri.ImportTypeMapping (typeof (EnumDefaultValueNF));
  185. sx.ExportTypeMapping (tm);
  186. Assert.AreEqual (1, schemas.Count, "#3");
  187. sw = new StringWriter ();
  188. schemas[0].Write (sw);
  189. Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
  190. "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
  191. #if NET_2_0
  192. "<xs:schema xmlns:tns=\"NSEnumDefaultValueNF\" elementFormDefault=\"qualified\" targetNamespace=\"NSEnumDefaultValueNF\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
  193. #else
  194. "<xs:schema xmlns:tns=\"NSEnumDefaultValueNF\" targetNamespace=\"NSEnumDefaultValueNF\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
  195. #endif
  196. " <xs:simpleType name=\"EnumDefaultValueNF\">{0}" +
  197. " <xs:restriction base=\"xs:string\">{0}" +
  198. " <xs:enumeration value=\"e1\" />{0}" +
  199. " <xs:enumeration value=\"e2\" />{0}" +
  200. " <xs:enumeration value=\"e3\" />{0}" +
  201. " </xs:restriction>{0}" +
  202. " </xs:simpleType>{0}" +
  203. "</xs:schema>", Environment.NewLine), sw.ToString (), "#4");
  204. }
  205. [Test]
  206. [Category ("NotWorking")]
  207. public void ExportXsdPrimitive ()
  208. {
  209. ArrayList types = new ArrayList ();
  210. types.Add (new TypeDescription (typeof (object), true, "anyType", "Object"));
  211. types.Add (new TypeDescription (typeof (byte), true, "unsignedByte", "Byte"));
  212. types.Add (new TypeDescription (typeof (sbyte), true, "byte", "Byte"));
  213. types.Add (new TypeDescription (typeof (bool), true, "boolean", "Boolean"));
  214. types.Add (new TypeDescription (typeof (short), true, "short", "Short"));
  215. types.Add (new TypeDescription (typeof (int), true, "int", "Int"));
  216. types.Add (new TypeDescription (typeof (long), true, "long", "Long"));
  217. types.Add (new TypeDescription (typeof (float), true, "float", "Float"));
  218. types.Add (new TypeDescription (typeof (double), true, "double", "Double"));
  219. types.Add (new TypeDescription (typeof (decimal), true, "decimal", "Decimal"));
  220. types.Add (new TypeDescription (typeof (ushort), true, "unsignedShort", "UnsignedShort"));
  221. types.Add (new TypeDescription (typeof (uint), true, "unsignedInt", "UnsignedInt"));
  222. types.Add (new TypeDescription (typeof (ulong), true, "unsignedLong", "UnsignedLong"));
  223. types.Add (new TypeDescription (typeof (DateTime), true, "dateTime", "DateTime"));
  224. #if NET_2_0
  225. types.Add (new TypeDescription (typeof (XmlQualifiedName), true, "QName", "QName", true));
  226. #else
  227. types.Add (new TypeDescription (typeof (XmlQualifiedName), true, "QName", "QName"));
  228. #endif
  229. types.Add (new TypeDescription (typeof (string), true, "string", "String", true));
  230. foreach (TypeDescription typeDesc in types) {
  231. SoapReflectionImporter ri = new SoapReflectionImporter (typeDesc.Type.Name);
  232. XmlSchemas schemas = new XmlSchemas ();
  233. SoapSchemaExporter sx = new SoapSchemaExporter (schemas);
  234. XmlTypeMapping tm = ri.ImportTypeMapping (typeDesc.Type);
  235. sx.ExportTypeMapping (tm);
  236. Assert.AreEqual (0, schemas.Count, typeDesc.Type.FullName + "#1");
  237. }
  238. }
  239. [Test]
  240. [Category ("NotWorking")]
  241. public void ExportXsdPrimitive_ByteArray ()
  242. {
  243. SoapReflectionImporter ri = new SoapReflectionImporter ("ByteArray");
  244. XmlSchemas schemas = new XmlSchemas ();
  245. SoapSchemaExporter sx = new SoapSchemaExporter (schemas);
  246. XmlTypeMapping tm = ri.ImportTypeMapping (typeof (byte[]));
  247. sx.ExportTypeMapping (tm);
  248. Assert.AreEqual (0, schemas.Count, "#1");
  249. }
  250. [Test]
  251. [Category ("NotWorking")]
  252. public void ExportXsdPrimitive_Arrays ()
  253. {
  254. ArrayList types = new ArrayList ();
  255. types.Add (new TypeDescription (typeof (object[]), true, "anyType", "AnyType"));
  256. types.Add (new TypeDescription (typeof (sbyte[]), true, "byte", "Byte"));
  257. types.Add (new TypeDescription (typeof (bool[]), true, "boolean", "Boolean"));
  258. types.Add (new TypeDescription (typeof (short[]), true, "short", "Short"));
  259. types.Add (new TypeDescription (typeof (int[]), true, "int", "Int"));
  260. types.Add (new TypeDescription (typeof (long[]), true, "long", "Long"));
  261. types.Add (new TypeDescription (typeof (float[]), true, "float", "Float"));
  262. types.Add (new TypeDescription (typeof (double[]), true, "double", "Double"));
  263. types.Add (new TypeDescription (typeof (decimal[]), true, "decimal", "Decimal"));
  264. types.Add (new TypeDescription (typeof (ushort[]), true, "unsignedShort", "UnsignedShort"));
  265. types.Add (new TypeDescription (typeof (uint[]), true, "unsignedInt", "UnsignedInt"));
  266. types.Add (new TypeDescription (typeof (ulong[]), true, "unsignedLong", "UnsignedLong"));
  267. types.Add (new TypeDescription (typeof (DateTime[]), true, "dateTime", "DateTime"));
  268. #if NET_2_0
  269. types.Add (new TypeDescription (typeof (XmlQualifiedName[]), true, "QName", "QName", true));
  270. #else
  271. types.Add (new TypeDescription (typeof (XmlQualifiedName[]), true, "QName", "QName"));
  272. #endif
  273. types.Add (new TypeDescription (typeof (string[]), true, "string", "String", true));
  274. foreach (TypeDescription typeDesc in types) {
  275. SoapReflectionImporter ri = new SoapReflectionImporter (typeDesc.Type.Name);
  276. XmlSchemas schemas = new XmlSchemas ();
  277. SoapSchemaExporter sx = new SoapSchemaExporter (schemas);
  278. XmlTypeMapping tm = ri.ImportTypeMapping (typeDesc.Type);
  279. sx.ExportTypeMapping (tm);
  280. Assert.AreEqual (1, schemas.Count, typeDesc.Type.FullName + "#1");
  281. StringWriter sw = new StringWriter ();
  282. schemas[0].Write (sw);
  283. Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
  284. "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
  285. #if NET_2_0
  286. "<xs:schema xmlns:tns=\"{1}\" elementFormDefault=\"qualified\" targetNamespace=\"{1}\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
  287. #else
  288. "<xs:schema xmlns:tns=\"{1}\" targetNamespace=\"{1}\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
  289. #endif
  290. " <xs:import namespace=\"http://schemas.xmlsoap.org/soap/encoding/\" />{0}" +
  291. " <xs:import namespace=\"http://schemas.xmlsoap.org/wsdl/\" />{0}" +
  292. " <xs:complexType name=\"ArrayOf{2}\">{0}" +
  293. " <xs:complexContent mixed=\"false\">{0}" +
  294. " <xs:restriction xmlns:q1=\"http://schemas.xmlsoap.org/soap/encoding/\" base=\"q1:Array\">{0}" +
  295. " <xs:attribute d5p1:arrayType=\"xs:{3}[]\" ref=\"q1:arrayType\" xmlns:d5p1=\"http://schemas.xmlsoap.org/wsdl/\" />{0}" +
  296. " </xs:restriction>{0}" +
  297. " </xs:complexContent>{0}" +
  298. " </xs:complexType>{0}" +
  299. "</xs:schema>", Environment.NewLine, typeDesc.Type.Name, typeDesc.ArrayType, typeDesc.XmlType,
  300. typeDesc.XsdType ? "xs" : "tns", typeDesc.IsNillable ? "nillable=\"true\" " : ""),
  301. sw.ToString (), typeDesc.Type.FullName + "#2");
  302. }
  303. }
  304. [Test]
  305. [Category ("NotWorking")]
  306. public void ExportNonXsdPrimitive_Guid ()
  307. {
  308. SoapReflectionImporter ri = new SoapReflectionImporter ("NSPrimGuid");
  309. XmlSchemas schemas = new XmlSchemas ();
  310. SoapSchemaExporter sx = new SoapSchemaExporter (schemas);
  311. XmlTypeMapping tm = ri.ImportTypeMapping (typeof (Guid));
  312. sx.ExportTypeMapping (tm);
  313. Assert.AreEqual (1, schemas.Count, "#1");
  314. StringWriter sw = new StringWriter ();
  315. schemas[0].Write (sw);
  316. Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
  317. "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
  318. #if NET_2_0
  319. "<xs:schema xmlns:tns=\"http://microsoft.com/wsdl/types/\" elementFormDefault=\"qualified\" targetNamespace=\"http://microsoft.com/wsdl/types/\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
  320. #else
  321. "<xs:schema xmlns:tns=\"http://microsoft.com/wsdl/types/\" targetNamespace=\"http://microsoft.com/wsdl/types/\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
  322. #endif
  323. " <xs:simpleType name=\"guid\">{0}" +
  324. " <xs:restriction base=\"xs:string\">{0}" +
  325. " <xs:pattern value=\"[0-9a-fA-F]{{8}}-[0-9a-fA-F]{{4}}-[0-9a-fA-F]{{4}}-[0-9a-fA-F]{{4}}-[0-9a-fA-F]{{12}}\" />{0}" +
  326. " </xs:restriction>{0}" +
  327. " </xs:simpleType>{0}" +
  328. "</xs:schema>", Environment.NewLine), sw.ToString (), "#2");
  329. }
  330. [Test]
  331. [Category ("NotWorking")]
  332. public void ExportNonXsdPrimitive_Char ()
  333. {
  334. SoapReflectionImporter ri = new SoapReflectionImporter ("NSPrimChar");
  335. XmlSchemas schemas = new XmlSchemas ();
  336. SoapSchemaExporter sx = new SoapSchemaExporter (schemas);
  337. XmlTypeMapping tm = ri.ImportTypeMapping (typeof (Char));
  338. sx.ExportTypeMapping (tm);
  339. Assert.AreEqual (1, schemas.Count, "#1");
  340. StringWriter sw = new StringWriter ();
  341. schemas[0].Write (sw);
  342. Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
  343. "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
  344. #if NET_2_0
  345. "<xs:schema xmlns:tns=\"http://microsoft.com/wsdl/types/\" elementFormDefault=\"qualified\" targetNamespace=\"http://microsoft.com/wsdl/types/\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
  346. #else
  347. "<xs:schema xmlns:tns=\"http://microsoft.com/wsdl/types/\" targetNamespace=\"http://microsoft.com/wsdl/types/\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
  348. #endif
  349. " <xs:simpleType name=\"char\">{0}" +
  350. " <xs:restriction base=\"xs:unsignedShort\" />{0}" +
  351. " </xs:simpleType>{0}" +
  352. "</xs:schema>", Environment.NewLine), sw.ToString (), "#2");
  353. }
  354. public class Employee : IXmlSerializable
  355. {
  356. private string _firstName;
  357. private string _lastName;
  358. private string _address;
  359. public XmlSchema GetSchema ()
  360. {
  361. return null;
  362. }
  363. public void WriteXml (XmlWriter writer)
  364. {
  365. writer.WriteStartElement ("employee", "urn:devx-com");
  366. writer.WriteAttributeString ("firstName", _firstName);
  367. writer.WriteAttributeString ("lastName", _lastName);
  368. writer.WriteAttributeString ("address", _address);
  369. writer.WriteEndElement ();
  370. }
  371. public void ReadXml (XmlReader reader)
  372. {
  373. XmlNodeType type = reader.MoveToContent ();
  374. if (type == XmlNodeType.Element && reader.LocalName == "employee") {
  375. _firstName = reader["firstName"];
  376. _lastName = reader["lastName"];
  377. _address = reader["address"];
  378. }
  379. }
  380. }
  381. private class TypeDescription
  382. {
  383. public TypeDescription (Type type, bool xsdType, string xmlType, string arrayType)
  384. : this (type, xsdType, xmlType, arrayType, false)
  385. {
  386. }
  387. public TypeDescription (Type type, bool xsdType, string xmlType, string arrayType, bool isNillable)
  388. {
  389. _type = type;
  390. _xsdType = xsdType;
  391. _xmlType = xmlType;
  392. _arrayType = arrayType;
  393. _isNillable = isNillable;
  394. }
  395. public Type Type
  396. {
  397. get { return _type; }
  398. }
  399. public string XmlType
  400. {
  401. get { return _xmlType; }
  402. }
  403. public string ArrayType
  404. {
  405. get { return _arrayType; }
  406. }
  407. public bool XsdType
  408. {
  409. get { return _xsdType; }
  410. }
  411. public bool IsNillable
  412. {
  413. get { return _isNillable; }
  414. }
  415. private Type _type;
  416. private bool _xsdType;
  417. private string _xmlType;
  418. private string _arrayType;
  419. private bool _isNillable;
  420. }
  421. }
  422. }