SoapSchemaExporterTests.cs 52 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165
  1. //
  2. // System.Xml.Serialization.SoapSchemaExporterTests
  3. //
  4. // Author:
  5. // Gert Driesen ([email protected])
  6. //
  7. // (C) 2005 Novell
  8. //
  9. #if !MOBILE
  10. using System;
  11. using System.Collections;
  12. using System.Globalization;
  13. using System.IO;
  14. using System.Xml;
  15. using System.Xml.Schema;
  16. using System.Xml.Serialization;
  17. using NUnit.Framework;
  18. using MonoTests.System.Xml.TestClasses;
  19. namespace MonoTests.System.XmlSerialization
  20. {
  21. [TestFixture]
  22. public class SoapSchemaExporterTests
  23. {
  24. private XmlSchemas Export (Type type)
  25. {
  26. return Export (type, string.Empty);
  27. }
  28. private XmlSchemas Export (Type type, string defaultNamespace)
  29. {
  30. SoapReflectionImporter ri = new SoapReflectionImporter (defaultNamespace);
  31. XmlSchemas schemas = new XmlSchemas ();
  32. SoapSchemaExporter sx = new SoapSchemaExporter (schemas);
  33. XmlTypeMapping tm = ri.ImportTypeMapping (type);
  34. sx.ExportTypeMapping (tm);
  35. return schemas;
  36. }
  37. private XmlSchemas Export (Type type, SoapAttributeOverrides overrides)
  38. {
  39. return Export (type, overrides, string.Empty);
  40. }
  41. private XmlSchemas Export (Type type, SoapAttributeOverrides overrides, string defaultNamespace)
  42. {
  43. SoapReflectionImporter ri = new SoapReflectionImporter (overrides, defaultNamespace);
  44. XmlSchemas schemas = new XmlSchemas ();
  45. SoapSchemaExporter sx = new SoapSchemaExporter (schemas);
  46. XmlTypeMapping tm = ri.ImportTypeMapping (type);
  47. sx.ExportTypeMapping (tm);
  48. return schemas;
  49. }
  50. [Test]
  51. [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
  52. public void ExportStruct ()
  53. {
  54. XmlSchemas schemas = Export (typeof (TimeSpan), "NSTimeSpan");
  55. Assert.AreEqual (1, schemas.Count, "#1");
  56. StringWriter sw = new StringWriter ();
  57. schemas[0].Write (sw);
  58. Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
  59. "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
  60. #if NET_2_0
  61. "<xs:schema xmlns:tns=\"NSTimeSpan\" elementFormDefault=\"qualified\" targetNamespace=\"NSTimeSpan\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
  62. #else
  63. "<xs:schema xmlns:tns=\"NSTimeSpan\" targetNamespace=\"NSTimeSpan\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
  64. #endif
  65. " <xs:complexType name=\"TimeSpan\" />{0}" +
  66. "</xs:schema>", Environment.NewLine), sw.ToString (), "#2");
  67. schemas = Export (typeof (TimeSpan));
  68. Assert.AreEqual (1, schemas.Count, "#3");
  69. sw = new StringWriter ();
  70. schemas[0].Write (sw);
  71. Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
  72. "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
  73. #if NET_2_0
  74. "<xs:schema elementFormDefault=\"qualified\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
  75. #else
  76. "<xs:schema xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
  77. #endif
  78. " <xs:complexType name=\"TimeSpan\" />{0}" +
  79. "</xs:schema>", Environment.NewLine), sw.ToString (), "#4");
  80. }
  81. [Test]
  82. [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
  83. /*
  84. #if NET_2_0
  85. [Category ("NotWorking")] // minOccurs is 1 on Mono
  86. #endif
  87. */
  88. public void ExportClass_SimpleClass ()
  89. {
  90. SoapAttributeOverrides overrides = new SoapAttributeOverrides ();
  91. SoapAttributes attr = new SoapAttributes ();
  92. SoapElementAttribute element = new SoapElementAttribute ();
  93. element.ElementName = "saying";
  94. element.IsNullable = true;
  95. attr.SoapElement = element;
  96. overrides.Add (typeof (SimpleClass), "something", attr);
  97. XmlSchemas schemas = Export (typeof (SimpleClass), overrides, "NSSimpleClass");
  98. Assert.AreEqual (1, schemas.Count, "#1");
  99. StringWriter sw = new StringWriter ();
  100. schemas[0].Write (sw);
  101. Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
  102. "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
  103. #if NET_2_0
  104. "<xs:schema xmlns:tns=\"NSSimpleClass\" elementFormDefault=\"qualified\" targetNamespace=\"NSSimpleClass\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
  105. #else
  106. "<xs:schema xmlns:tns=\"NSSimpleClass\" targetNamespace=\"NSSimpleClass\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
  107. #endif
  108. " <xs:complexType name=\"SimpleClass\">{0}" +
  109. " <xs:sequence>{0}" +
  110. #if NET_2_0
  111. " <xs:element minOccurs=\"0\" maxOccurs=\"1\" form=\"unqualified\" name=\"saying\" nillable=\"true\" type=\"xs:string\" />{0}" +
  112. #else
  113. " <xs:element minOccurs=\"1\" maxOccurs=\"1\" name=\"saying\" type=\"xs:string\" />{0}" +
  114. #endif
  115. " </xs:sequence>{0}" +
  116. " </xs:complexType>{0}" +
  117. "</xs:schema>", Environment.NewLine), sw.ToString (), "#2");
  118. }
  119. [Test]
  120. [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
  121. public void ExportClass_StringCollection ()
  122. {
  123. XmlSchemas schemas = Export (typeof (StringCollection), "NSStringCollection");
  124. Assert.AreEqual (1, schemas.Count, "#1");
  125. StringWriter sw = new StringWriter ();
  126. schemas[0].Write (sw);
  127. Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
  128. "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
  129. #if NET_2_0
  130. "<xs:schema xmlns:tns=\"NSStringCollection\" elementFormDefault=\"qualified\" targetNamespace=\"NSStringCollection\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
  131. #else
  132. "<xs:schema xmlns:tns=\"NSStringCollection\" targetNamespace=\"NSStringCollection\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
  133. #endif
  134. " <xs:import namespace=\"http://schemas.xmlsoap.org/soap/encoding/\" />{0}" +
  135. " <xs:import namespace=\"http://schemas.xmlsoap.org/wsdl/\" />{0}" +
  136. " <xs:complexType name=\"ArrayOfString\">{0}" +
  137. " <xs:complexContent mixed=\"false\">{0}" +
  138. " <xs:restriction xmlns:q1=\"http://schemas.xmlsoap.org/soap/encoding/\" base=\"q1:Array\">{0}" +
  139. " <xs:attribute d5p1:arrayType=\"xs:string[]\" ref=\"q1:arrayType\" xmlns:d5p1=\"http://schemas.xmlsoap.org/wsdl/\" />{0}" +
  140. " </xs:restriction>{0}" +
  141. " </xs:complexContent>{0}" +
  142. " </xs:complexType>{0}" +
  143. "</xs:schema>", Environment.NewLine), sw.ToString (), "#2");
  144. }
  145. [Test]
  146. [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
  147. public void ExportClass_StringCollectionContainer ()
  148. {
  149. XmlSchemas schemas = Export (typeof (StringCollectionContainer), "NSStringCollectionContainer");
  150. Assert.AreEqual (1, schemas.Count, "#1");
  151. StringWriter sw = new StringWriter ();
  152. schemas[0].Write (sw);
  153. Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
  154. "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
  155. #if NET_2_0
  156. "<xs:schema xmlns:tns=\"NSStringCollectionContainer\" elementFormDefault=\"qualified\" targetNamespace=\"NSStringCollectionContainer\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
  157. #else
  158. "<xs:schema xmlns:tns=\"NSStringCollectionContainer\" targetNamespace=\"NSStringCollectionContainer\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
  159. #endif
  160. " <xs:import namespace=\"http://schemas.xmlsoap.org/soap/encoding/\" />{0}" +
  161. " <xs:import namespace=\"http://schemas.xmlsoap.org/wsdl/\" />{0}" +
  162. " <xs:complexType name=\"StringCollectionContainer\">{0}" +
  163. " <xs:sequence>{0}" +
  164. #if NET_2_0
  165. " <xs:element minOccurs=\"0\" maxOccurs=\"1\" form=\"unqualified\" name=\"Messages\" type=\"tns:ArrayOfString\" />{0}" +
  166. #else
  167. " <xs:element minOccurs=\"1\" maxOccurs=\"1\" name=\"Messages\" type=\"tns:ArrayOfString\" />{0}" +
  168. #endif
  169. " </xs:sequence>{0}" +
  170. " </xs:complexType>{0}" +
  171. " <xs:complexType name=\"ArrayOfString\">{0}" +
  172. " <xs:complexContent mixed=\"false\">{0}" +
  173. " <xs:restriction xmlns:q1=\"http://schemas.xmlsoap.org/soap/encoding/\" base=\"q1:Array\">{0}" +
  174. " <xs:attribute d5p1:arrayType=\"xs:string[]\" ref=\"q1:arrayType\" xmlns:d5p1=\"http://schemas.xmlsoap.org/wsdl/\" />{0}" +
  175. " </xs:restriction>{0}" +
  176. " </xs:complexContent>{0}" +
  177. " </xs:complexType>{0}" +
  178. "</xs:schema>", Environment.NewLine), sw.ToString (), "#2");
  179. }
  180. [Test]
  181. [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
  182. public void ExportClass_ArrayContainer ()
  183. {
  184. XmlSchemas schemas = Export (typeof (ArrayContainer), "NSArrayContainer");
  185. Assert.AreEqual (1, schemas.Count, "#1");
  186. StringWriter sw = new StringWriter ();
  187. schemas[0].Write (sw);
  188. Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
  189. "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
  190. #if NET_2_0
  191. "<xs:schema xmlns:tns=\"NSArrayContainer\" elementFormDefault=\"qualified\" targetNamespace=\"NSArrayContainer\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
  192. #else
  193. "<xs:schema xmlns:tns=\"NSArrayContainer\" targetNamespace=\"NSArrayContainer\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
  194. #endif
  195. " <xs:import namespace=\"http://schemas.xmlsoap.org/soap/encoding/\" />{0}" +
  196. " <xs:import namespace=\"http://schemas.xmlsoap.org/wsdl/\" />{0}" +
  197. " <xs:complexType name=\"ArrayContainer\">{0}" +
  198. " <xs:sequence>{0}" +
  199. #if NET_2_0
  200. " <xs:element minOccurs=\"0\" maxOccurs=\"1\" form=\"unqualified\" name=\"items\" type=\"tns:ArrayOfAnyType\" />{0}" +
  201. #else
  202. " <xs:element minOccurs=\"1\" maxOccurs=\"1\" name=\"items\" type=\"tns:ArrayOfAnyType\" />{0}" +
  203. #endif
  204. " </xs:sequence>{0}" +
  205. " </xs:complexType>{0}" +
  206. " <xs:complexType name=\"ArrayOfAnyType\">{0}" +
  207. " <xs:complexContent mixed=\"false\">{0}" +
  208. " <xs:restriction xmlns:q1=\"http://schemas.xmlsoap.org/soap/encoding/\" base=\"q1:Array\">{0}" +
  209. " <xs:attribute d5p1:arrayType=\"xs:anyType[]\" ref=\"q1:arrayType\" xmlns:d5p1=\"http://schemas.xmlsoap.org/wsdl/\" />{0}" +
  210. " </xs:restriction>{0}" +
  211. " </xs:complexContent>{0}" +
  212. " </xs:complexType>{0}" +
  213. "</xs:schema>", Environment.NewLine), sw.ToString (), "#2");
  214. }
  215. [Test]
  216. [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
  217. public void ExportClass_ClassArrayContainer ()
  218. {
  219. XmlSchemas schemas = Export (typeof (ClassArrayContainer), "NSClassArrayContainer");
  220. Assert.AreEqual (1, schemas.Count, "#1");
  221. StringWriter sw = new StringWriter ();
  222. schemas[0].Write (sw);
  223. Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
  224. "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
  225. #if NET_2_0
  226. "<xs:schema xmlns:tns=\"NSClassArrayContainer\" elementFormDefault=\"qualified\" targetNamespace=\"NSClassArrayContainer\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
  227. #else
  228. "<xs:schema xmlns:tns=\"NSClassArrayContainer\" targetNamespace=\"NSClassArrayContainer\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
  229. #endif
  230. " <xs:import namespace=\"http://schemas.xmlsoap.org/soap/encoding/\" />{0}" +
  231. " <xs:import namespace=\"http://schemas.xmlsoap.org/wsdl/\" />{0}" +
  232. " <xs:complexType name=\"ClassArrayContainer\">{0}" +
  233. " <xs:sequence>{0}" +
  234. #if NET_2_0
  235. " <xs:element minOccurs=\"0\" maxOccurs=\"1\" form=\"unqualified\" name=\"items\" type=\"tns:ArrayOfSimpleClass\" />{0}" +
  236. #else
  237. " <xs:element minOccurs=\"1\" maxOccurs=\"1\" name=\"items\" type=\"tns:ArrayOfSimpleClass\" />{0}" +
  238. #endif
  239. " </xs:sequence>{0}" +
  240. " </xs:complexType>{0}" +
  241. " <xs:complexType name=\"ArrayOfSimpleClass\">{0}" +
  242. " <xs:complexContent mixed=\"false\">{0}" +
  243. " <xs:restriction xmlns:q1=\"http://schemas.xmlsoap.org/soap/encoding/\" base=\"q1:Array\">{0}" +
  244. " <xs:attribute d5p1:arrayType=\"tns:SimpleClass[]\" ref=\"q1:arrayType\" xmlns:d5p1=\"http://schemas.xmlsoap.org/wsdl/\" />{0}" +
  245. " </xs:restriction>{0}" +
  246. " </xs:complexContent>{0}" +
  247. " </xs:complexType>{0}" +
  248. " <xs:complexType name=\"SimpleClass\">{0}" +
  249. " <xs:sequence>{0}" +
  250. #if NET_2_0
  251. " <xs:element minOccurs=\"0\" maxOccurs=\"1\" form=\"unqualified\" name=\"something\" type=\"xs:string\" />{0}" +
  252. #else
  253. " <xs:element minOccurs=\"1\" maxOccurs=\"1\" name=\"something\" type=\"xs:string\" />{0}" +
  254. #endif
  255. " </xs:sequence>{0}" +
  256. " </xs:complexType>{0}" +
  257. "</xs:schema>", Environment.NewLine), sw.ToString (), "#2");
  258. }
  259. [Test]
  260. [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
  261. public void ExportClass_SimpleClassWithXmlAttributes ()
  262. {
  263. XmlSchemas schemas = Export (typeof (SimpleClassWithXmlAttributes), "NSSimpleClassWithXmlAttributes");
  264. Assert.AreEqual (1, schemas.Count, "#1");
  265. StringWriter sw = new StringWriter ();
  266. schemas[0].Write (sw);
  267. Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
  268. "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
  269. #if NET_2_0
  270. "<xs:schema xmlns:tns=\"NSSimpleClassWithXmlAttributes\" elementFormDefault=\"qualified\" targetNamespace=\"NSSimpleClassWithXmlAttributes\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
  271. #else
  272. "<xs:schema xmlns:tns=\"NSSimpleClassWithXmlAttributes\" targetNamespace=\"NSSimpleClassWithXmlAttributes\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
  273. #endif
  274. " <xs:complexType name=\"SimpleClassWithXmlAttributes\">{0}" +
  275. " <xs:sequence>{0}" +
  276. #if NET_2_0
  277. " <xs:element minOccurs=\"0\" maxOccurs=\"1\" form=\"unqualified\" name=\"something\" type=\"xs:string\" />{0}" +
  278. #else
  279. " <xs:element minOccurs=\"1\" maxOccurs=\"1\" name=\"something\" type=\"xs:string\" />{0}" +
  280. #endif
  281. " </xs:sequence>{0}" +
  282. " </xs:complexType>{0}" +
  283. "</xs:schema>", Environment.NewLine), sw.ToString (), "#2");
  284. }
  285. [Test]
  286. [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
  287. public void ExportClass_Field ()
  288. {
  289. XmlSchemas schemas = Export (typeof (Field), "NSField");
  290. Assert.AreEqual (1, schemas.Count, "#1");
  291. StringWriter sw = new StringWriter ();
  292. schemas[0].Write (sw);
  293. Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
  294. "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
  295. #if NET_2_0
  296. "<xs:schema xmlns:tns=\"NSField\" elementFormDefault=\"qualified\" targetNamespace=\"NSField\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
  297. #else
  298. "<xs:schema xmlns:tns=\"NSField\" targetNamespace=\"NSField\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
  299. #endif
  300. " <xs:import namespace=\"http://schemas.xmlsoap.org/soap/encoding/\" />{0}" +
  301. " <xs:import namespace=\"http://schemas.xmlsoap.org/wsdl/\" />{0}" +
  302. " <xs:complexType name=\"Field\">{0}" +
  303. " <xs:sequence>{0}" +
  304. #if NET_2_0
  305. " <xs:element minOccurs=\"1\" maxOccurs=\"1\" form=\"unqualified\" name=\"Flags1\" type=\"tns:FlagEnum\" />{0}" +
  306. " <xs:element minOccurs=\"1\" maxOccurs=\"1\" form=\"unqualified\" name=\"Flags2\" type=\"tns:FlagEnum\" />{0}" +
  307. " <xs:element minOccurs=\"1\" maxOccurs=\"1\" form=\"unqualified\" name=\"Flags3\" type=\"tns:FlagEnum\" />{0}" +
  308. " <xs:element minOccurs=\"1\" maxOccurs=\"1\" form=\"unqualified\" name=\"Flags4\" type=\"tns:FlagEnum\" />{0}" +
  309. " <xs:element minOccurs=\"1\" maxOccurs=\"1\" form=\"unqualified\" name=\"Modifiers\" type=\"tns:MapModifiers\" />{0}" +
  310. " <xs:element minOccurs=\"1\" maxOccurs=\"1\" form=\"unqualified\" name=\"Modifiers2\" type=\"tns:MapModifiers\" />{0}" +
  311. " <xs:element minOccurs=\"1\" maxOccurs=\"1\" form=\"unqualified\" name=\"Modifiers3\" type=\"tns:MapModifiers\" />{0}" +
  312. " <xs:element minOccurs=\"1\" maxOccurs=\"1\" form=\"unqualified\" name=\"Modifiers4\" type=\"tns:MapModifiers\" />{0}" +
  313. " <xs:element minOccurs=\"1\" maxOccurs=\"1\" form=\"unqualified\" name=\"Modifiers5\" type=\"tns:MapModifiers\" />{0}" +
  314. " <xs:element minOccurs=\"0\" maxOccurs=\"1\" form=\"unqualified\" name=\"Names\" type=\"tns:ArrayOfString\" />{0}" +
  315. " <xs:element minOccurs=\"0\" maxOccurs=\"1\" form=\"unqualified\" name=\"Street\" type=\"xs:string\" />{0}" +
  316. #else
  317. " <xs:element minOccurs=\"1\" maxOccurs=\"1\" name=\"Flags1\" type=\"tns:FlagEnum\" />{0}" +
  318. " <xs:element minOccurs=\"1\" maxOccurs=\"1\" name=\"Flags2\" type=\"tns:FlagEnum\" />{0}" +
  319. " <xs:element minOccurs=\"1\" maxOccurs=\"1\" name=\"Flags3\" type=\"tns:FlagEnum\" />{0}" +
  320. " <xs:element minOccurs=\"1\" maxOccurs=\"1\" name=\"Flags4\" type=\"tns:FlagEnum\" />{0}" +
  321. " <xs:element minOccurs=\"1\" maxOccurs=\"1\" name=\"Modifiers\" type=\"tns:MapModifiers\" />{0}" +
  322. " <xs:element minOccurs=\"1\" maxOccurs=\"1\" name=\"Modifiers2\" type=\"tns:MapModifiers\" />{0}" +
  323. " <xs:element minOccurs=\"1\" maxOccurs=\"1\" name=\"Modifiers3\" type=\"tns:MapModifiers\" />{0}" +
  324. " <xs:element minOccurs=\"1\" maxOccurs=\"1\" name=\"Modifiers4\" type=\"tns:MapModifiers\" />{0}" +
  325. " <xs:element minOccurs=\"1\" maxOccurs=\"1\" name=\"Modifiers5\" type=\"tns:MapModifiers\" />{0}" +
  326. " <xs:element minOccurs=\"1\" maxOccurs=\"1\" name=\"Names\" type=\"tns:ArrayOfString\" />{0}" +
  327. " <xs:element minOccurs=\"1\" maxOccurs=\"1\" name=\"Street\" type=\"xs:string\" />{0}" +
  328. #endif
  329. " </xs:sequence>{0}" +
  330. " </xs:complexType>{0}" +
  331. " <xs:simpleType name=\"FlagEnum\">{0}" +
  332. " <xs:list>{0}" +
  333. " <xs:simpleType>{0}" +
  334. " <xs:restriction base=\"xs:string\">{0}" +
  335. " <xs:enumeration value=\"e1\" />{0}" +
  336. " <xs:enumeration value=\"e2\" />{0}" +
  337. " <xs:enumeration value=\"e4\" />{0}" +
  338. " </xs:restriction>{0}" +
  339. " </xs:simpleType>{0}" +
  340. " </xs:list>{0}" +
  341. " </xs:simpleType>{0}" +
  342. " <xs:simpleType name=\"MapModifiers\">{0}" +
  343. " <xs:list>{0}" +
  344. " <xs:simpleType>{0}" +
  345. " <xs:restriction base=\"xs:string\">{0}" +
  346. " <xs:enumeration value=\"Public\" />{0}" +
  347. " <xs:enumeration value=\"Protected\" />{0}" +
  348. " </xs:restriction>{0}" +
  349. " </xs:simpleType>{0}" +
  350. " </xs:list>{0}" +
  351. " </xs:simpleType>{0}" +
  352. " <xs:complexType name=\"ArrayOfString\">{0}" +
  353. " <xs:complexContent mixed=\"false\">{0}" +
  354. " <xs:restriction xmlns:q1=\"http://schemas.xmlsoap.org/soap/encoding/\" base=\"q1:Array\">{0}" +
  355. " <xs:attribute d5p1:arrayType=\"xs:string[]\" ref=\"q1:arrayType\" xmlns:d5p1=\"http://schemas.xmlsoap.org/wsdl/\" />{0}" +
  356. " </xs:restriction>{0}" +
  357. " </xs:complexContent>{0}" +
  358. " </xs:complexType>{0}" +
  359. "</xs:schema>", Environment.NewLine), sw.ToString (), "#2");
  360. }
  361. [Test]
  362. [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
  363. public void ExportClass_MyList ()
  364. {
  365. XmlSchemas schemas = Export (typeof (MyList), "NSMyList");
  366. Assert.AreEqual (1, schemas.Count, "#1");
  367. StringWriter sw = new StringWriter ();
  368. schemas[0].Write (sw);
  369. Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
  370. "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
  371. #if NET_2_0
  372. "<xs:schema xmlns:tns=\"NSMyList\" elementFormDefault=\"qualified\" targetNamespace=\"NSMyList\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
  373. #else
  374. "<xs:schema xmlns:tns=\"NSMyList\" targetNamespace=\"NSMyList\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
  375. #endif
  376. " <xs:import namespace=\"http://schemas.xmlsoap.org/soap/encoding/\" />{0}" +
  377. " <xs:import namespace=\"http://schemas.xmlsoap.org/wsdl/\" />{0}" +
  378. " <xs:complexType name=\"ArrayOfAnyType\">{0}" +
  379. " <xs:complexContent mixed=\"false\">{0}" +
  380. " <xs:restriction xmlns:q1=\"http://schemas.xmlsoap.org/soap/encoding/\" base=\"q1:Array\">{0}" +
  381. " <xs:attribute d5p1:arrayType=\"xs:anyType[]\" ref=\"q1:arrayType\" xmlns:d5p1=\"http://schemas.xmlsoap.org/wsdl/\" />{0}" +
  382. " </xs:restriction>{0}" +
  383. " </xs:complexContent>{0}" +
  384. " </xs:complexType>{0}" +
  385. "</xs:schema>", Environment.NewLine), sw.ToString (), "#2");
  386. }
  387. [Test]
  388. [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
  389. public void ExportClass_Container ()
  390. {
  391. XmlSchemas schemas = Export (typeof (Container), "NSContainer");
  392. Assert.AreEqual (1, schemas.Count, "#1");
  393. StringWriter sw = new StringWriter ();
  394. schemas[0].Write (sw);
  395. Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
  396. "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
  397. #if NET_2_0
  398. "<xs:schema xmlns:tns=\"NSContainer\" elementFormDefault=\"qualified\" targetNamespace=\"NSContainer\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
  399. #else
  400. "<xs:schema xmlns:tns=\"NSContainer\" targetNamespace=\"NSContainer\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
  401. #endif
  402. " <xs:import namespace=\"http://schemas.xmlsoap.org/soap/encoding/\" />{0}" +
  403. " <xs:import namespace=\"http://schemas.xmlsoap.org/wsdl/\" />{0}" +
  404. " <xs:complexType name=\"Container\">{0}" +
  405. " <xs:sequence>{0}" +
  406. #if NET_2_0
  407. " <xs:element minOccurs=\"0\" maxOccurs=\"1\" form=\"unqualified\" name=\"Items\" type=\"tns:ArrayOfAnyType\" />{0}" +
  408. #else
  409. " <xs:element minOccurs=\"1\" maxOccurs=\"1\" name=\"Items\" type=\"tns:ArrayOfAnyType\" />{0}" +
  410. #endif
  411. " </xs:sequence>{0}" +
  412. " </xs:complexType>{0}" +
  413. " <xs:complexType name=\"ArrayOfAnyType\">{0}" +
  414. " <xs:complexContent mixed=\"false\">{0}" +
  415. " <xs:restriction xmlns:q1=\"http://schemas.xmlsoap.org/soap/encoding/\" base=\"q1:Array\">{0}" +
  416. " <xs:attribute d5p1:arrayType=\"xs:anyType[]\" ref=\"q1:arrayType\" xmlns:d5p1=\"http://schemas.xmlsoap.org/wsdl/\" />{0}" +
  417. " </xs:restriction>{0}" +
  418. " </xs:complexContent>{0}" +
  419. " </xs:complexType>{0}" +
  420. "</xs:schema>", Environment.NewLine), sw.ToString (), "#2");
  421. }
  422. [Test]
  423. [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
  424. public void ExportClass_Container2 ()
  425. {
  426. XmlSchemas schemas = Export (typeof (Container2), "NSContainer2");
  427. Assert.AreEqual (1, schemas.Count, "#1");
  428. StringWriter sw = new StringWriter ();
  429. schemas[0].Write (sw);
  430. Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
  431. "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
  432. #if NET_2_0
  433. "<xs:schema xmlns:tns=\"NSContainer2\" elementFormDefault=\"qualified\" targetNamespace=\"NSContainer2\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
  434. #else
  435. "<xs:schema xmlns:tns=\"NSContainer2\" targetNamespace=\"NSContainer2\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
  436. #endif
  437. " <xs:import namespace=\"http://schemas.xmlsoap.org/soap/encoding/\" />{0}" +
  438. " <xs:import namespace=\"http://schemas.xmlsoap.org/wsdl/\" />{0}" +
  439. " <xs:complexType name=\"Container2\">{0}" +
  440. " <xs:sequence>{0}" +
  441. #if NET_2_0
  442. " <xs:element minOccurs=\"0\" maxOccurs=\"1\" form=\"unqualified\" name=\"Items\" type=\"tns:ArrayOfAnyType\" />{0}" +
  443. #else
  444. " <xs:element minOccurs=\"1\" maxOccurs=\"1\" name=\"Items\" type=\"tns:ArrayOfAnyType\" />{0}" +
  445. #endif
  446. " </xs:sequence>{0}" +
  447. " </xs:complexType>{0}" +
  448. " <xs:complexType name=\"ArrayOfAnyType\">{0}" +
  449. " <xs:complexContent mixed=\"false\">{0}" +
  450. " <xs:restriction xmlns:q1=\"http://schemas.xmlsoap.org/soap/encoding/\" base=\"q1:Array\">{0}" +
  451. " <xs:attribute d5p1:arrayType=\"xs:anyType[]\" ref=\"q1:arrayType\" xmlns:d5p1=\"http://schemas.xmlsoap.org/wsdl/\" />{0}" +
  452. " </xs:restriction>{0}" +
  453. " </xs:complexContent>{0}" +
  454. " </xs:complexType>{0}" +
  455. "</xs:schema>", Environment.NewLine), sw.ToString (), "#2");
  456. }
  457. [Test]
  458. [ExpectedException (typeof (NotSupportedException))]
  459. public void ExportClass_MyElem ()
  460. {
  461. Export (typeof (MyElem), "NSMyElem");
  462. }
  463. [Test]
  464. [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
  465. [ExpectedException (typeof (NotSupportedException))] // The type System.Xml.XmlCDataSection may not be serialized with SOAP-encoded messages.
  466. public void ExportClass_CDataContainer ()
  467. {
  468. Export (typeof (CDataContainer), "NSCDataContainer");
  469. }
  470. [Test]
  471. [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
  472. [ExpectedException (typeof (NotSupportedException))] // The type System.Xml.XmlCDataSection may not be serialized with SOAP-encoded messages.
  473. public void ExportClass_NodeContainer ()
  474. {
  475. Export (typeof (NodeContainer), "NSNodeContainer");
  476. }
  477. [Test]
  478. [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
  479. public void ExportClass_Choices ()
  480. {
  481. XmlSchemas schemas = Export (typeof (Choices), "NSChoices");
  482. Assert.AreEqual (1, schemas.Count, "#1");
  483. StringWriter sw = new StringWriter ();
  484. schemas[0].Write (sw);
  485. Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
  486. "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
  487. #if NET_2_0
  488. "<xs:schema xmlns:tns=\"NSChoices\" elementFormDefault=\"qualified\" targetNamespace=\"NSChoices\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
  489. #else
  490. "<xs:schema xmlns:tns=\"NSChoices\" targetNamespace=\"NSChoices\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
  491. #endif
  492. " <xs:complexType name=\"Choices\">{0}" +
  493. " <xs:sequence>{0}" +
  494. #if NET_2_0
  495. " <xs:element minOccurs=\"0\" maxOccurs=\"1\" form=\"unqualified\" name=\"MyChoice\" type=\"xs:string\" />{0}" +
  496. " <xs:element minOccurs=\"1\" maxOccurs=\"1\" form=\"unqualified\" name=\"ItemType\" type=\"tns:ItemChoiceType\" />{0}" +
  497. #else
  498. " <xs:element minOccurs=\"1\" maxOccurs=\"1\" name=\"MyChoice\" type=\"xs:string\" />{0}" +
  499. " <xs:element minOccurs=\"1\" maxOccurs=\"1\" name=\"ItemType\" type=\"tns:ItemChoiceType\" />{0}" +
  500. #endif
  501. " </xs:sequence>{0}" +
  502. " </xs:complexType>{0}" +
  503. " <xs:simpleType name=\"ItemChoiceType\">{0}" +
  504. " <xs:restriction base=\"xs:string\">{0}" +
  505. " <xs:enumeration value=\"ChoiceZero\" />{0}" +
  506. " <xs:enumeration value=\"StrangeOne\" />{0}" +
  507. " <xs:enumeration value=\"ChoiceTwo\" />{0}" +
  508. " </xs:restriction>{0}" +
  509. " </xs:simpleType>{0}" +
  510. "</xs:schema>", Environment.NewLine), sw.ToString (), "#2");
  511. }
  512. [Test]
  513. [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
  514. public void ExportClass_WrongChoices ()
  515. {
  516. XmlSchemas schemas = Export (typeof (WrongChoices), "NSWrongChoices");
  517. Assert.AreEqual (1, schemas.Count, "#1");
  518. StringWriter sw = new StringWriter ();
  519. schemas[0].Write (sw);
  520. Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
  521. "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
  522. #if NET_2_0
  523. "<xs:schema xmlns:tns=\"NSWrongChoices\" elementFormDefault=\"qualified\" targetNamespace=\"NSWrongChoices\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
  524. #else
  525. "<xs:schema xmlns:tns=\"NSWrongChoices\" targetNamespace=\"NSWrongChoices\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
  526. #endif
  527. " <xs:complexType name=\"WrongChoices\">{0}" +
  528. " <xs:sequence>{0}" +
  529. #if NET_2_0
  530. " <xs:element minOccurs=\"0\" maxOccurs=\"1\" form=\"unqualified\" name=\"MyChoice\" type=\"xs:string\" />{0}" +
  531. " <xs:element minOccurs=\"1\" maxOccurs=\"1\" form=\"unqualified\" name=\"ItemType\" type=\"tns:ItemChoiceType\" />{0}" +
  532. #else
  533. " <xs:element minOccurs=\"1\" maxOccurs=\"1\" name=\"MyChoice\" type=\"xs:string\" />{0}" +
  534. " <xs:element minOccurs=\"1\" maxOccurs=\"1\" name=\"ItemType\" type=\"tns:ItemChoiceType\" />{0}" +
  535. #endif
  536. " </xs:sequence>{0}" +
  537. " </xs:complexType>{0}" +
  538. " <xs:simpleType name=\"ItemChoiceType\">{0}" +
  539. " <xs:restriction base=\"xs:string\">{0}" +
  540. " <xs:enumeration value=\"ChoiceZero\" />{0}" +
  541. " <xs:enumeration value=\"StrangeOne\" />{0}" +
  542. " <xs:enumeration value=\"ChoiceTwo\" />{0}" +
  543. " </xs:restriction>{0}" +
  544. " </xs:simpleType>{0}" +
  545. "</xs:schema>", Environment.NewLine), sw.ToString (), "#2");
  546. }
  547. [Test]
  548. [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
  549. public void ExportClass_TestSpace ()
  550. {
  551. XmlSchemas schemas = Export (typeof (TestSpace), "NSTestSpace");
  552. Assert.AreEqual (1, schemas.Count, "#1");
  553. StringWriter sw = new StringWriter ();
  554. schemas[0].Write (sw);
  555. Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
  556. "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
  557. #if NET_2_0
  558. "<xs:schema xmlns:tns=\"NSTestSpace\" elementFormDefault=\"qualified\" targetNamespace=\"NSTestSpace\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
  559. #else
  560. "<xs:schema xmlns:tns=\"NSTestSpace\" targetNamespace=\"NSTestSpace\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
  561. #endif
  562. " <xs:complexType name=\"TestSpace\">{0}" +
  563. " <xs:sequence>{0}" +
  564. #if NET_2_0
  565. " <xs:element minOccurs=\"1\" maxOccurs=\"1\" form=\"unqualified\" name=\"elem\" type=\"xs:int\" />{0}" +
  566. #else
  567. " <xs:element minOccurs=\"1\" maxOccurs=\"1\" name=\"elem\" type=\"xs:int\" />{0}" +
  568. #endif
  569. #if NET_2_0
  570. " <xs:element minOccurs=\"1\" maxOccurs=\"1\" form=\"unqualified\" name=\"attr\" type=\"xs:int\" />{0}" +
  571. #else
  572. " <xs:element minOccurs=\"1\" maxOccurs=\"1\" name=\"attr\" type=\"xs:int\" />{0}" +
  573. #endif
  574. " </xs:sequence>{0}" +
  575. " </xs:complexType>{0}" +
  576. "</xs:schema>", Environment.NewLine), sw.ToString (), "#2");
  577. }
  578. [Test]
  579. [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
  580. public void ExportClass_ReadOnlyProperties ()
  581. {
  582. XmlSchemas schemas = Export (typeof (ReadOnlyProperties), "NSReadOnlyProperties");
  583. Assert.AreEqual (1, schemas.Count, "#1");
  584. StringWriter sw = new StringWriter ();
  585. schemas[0].Write (sw);
  586. Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
  587. "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
  588. #if NET_2_0
  589. "<xs:schema xmlns:tns=\"NSReadOnlyProperties\" elementFormDefault=\"qualified\" targetNamespace=\"NSReadOnlyProperties\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
  590. #else
  591. "<xs:schema xmlns:tns=\"NSReadOnlyProperties\" targetNamespace=\"NSReadOnlyProperties\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
  592. #endif
  593. " <xs:complexType name=\"ReadOnlyProperties\" />{0}" +
  594. "</xs:schema>", Environment.NewLine), sw.ToString (), "#2");
  595. }
  596. [Test]
  597. [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
  598. public void ExportClass_ListDefaults ()
  599. {
  600. XmlSchemas schemas = Export (typeof (ListDefaults), "NSListDefaults");
  601. Assert.AreEqual (1, schemas.Count, "#1");
  602. StringWriter sw = new StringWriter ();
  603. schemas[0].Write (sw);
  604. Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
  605. "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
  606. #if NET_2_0
  607. "<xs:schema xmlns:tns=\"NSListDefaults\" elementFormDefault=\"qualified\" targetNamespace=\"NSListDefaults\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
  608. #else
  609. "<xs:schema xmlns:tns=\"NSListDefaults\" targetNamespace=\"NSListDefaults\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
  610. #endif
  611. " <xs:import namespace=\"http://schemas.xmlsoap.org/soap/encoding/\" />{0}" +
  612. " <xs:import namespace=\"http://schemas.xmlsoap.org/wsdl/\" />{0}" +
  613. " <xs:complexType name=\"ListDefaults\">{0}" +
  614. " <xs:sequence>{0}" +
  615. #if NET_2_0
  616. " <xs:element minOccurs=\"0\" maxOccurs=\"1\" form=\"unqualified\" name=\"list2\" type=\"tns:ArrayOfAnyType\" />{0}" +
  617. " <xs:element minOccurs=\"0\" maxOccurs=\"1\" form=\"unqualified\" name=\"list3\" type=\"tns:ArrayOfAnyType\" />{0}" +
  618. " <xs:element minOccurs=\"0\" maxOccurs=\"1\" form=\"unqualified\" name=\"list4\" type=\"tns:ArrayOfString\" />{0}" +
  619. " <xs:element minOccurs=\"0\" maxOccurs=\"1\" form=\"unqualified\" name=\"list5\" type=\"tns:ArrayOfAnyType\" />{0}" +
  620. " <xs:element minOccurs=\"0\" maxOccurs=\"1\" form=\"unqualified\" name=\"ed\" type=\"tns:SimpleClass\" />{0}" +
  621. " <xs:element minOccurs=\"0\" maxOccurs=\"1\" form=\"unqualified\" name=\"str\" type=\"xs:string\" />{0}" +
  622. #else
  623. " <xs:element minOccurs=\"1\" maxOccurs=\"1\" name=\"list2\" type=\"tns:ArrayOfAnyType\" />{0}" +
  624. " <xs:element minOccurs=\"1\" maxOccurs=\"1\" name=\"list3\" type=\"tns:ArrayOfAnyType\" />{0}" +
  625. " <xs:element minOccurs=\"1\" maxOccurs=\"1\" name=\"list4\" type=\"tns:ArrayOfString\" />{0}" +
  626. " <xs:element minOccurs=\"1\" maxOccurs=\"1\" name=\"list5\" type=\"tns:ArrayOfAnyType\" />{0}" +
  627. " <xs:element minOccurs=\"1\" maxOccurs=\"1\" name=\"ed\" type=\"tns:SimpleClass\" />{0}" +
  628. " <xs:element minOccurs=\"1\" maxOccurs=\"1\" name=\"str\" type=\"xs:string\" />{0}" +
  629. #endif
  630. " </xs:sequence>{0}" +
  631. " </xs:complexType>{0}" +
  632. " <xs:complexType name=\"ArrayOfAnyType\">{0}" +
  633. " <xs:complexContent mixed=\"false\">{0}" +
  634. " <xs:restriction xmlns:q1=\"http://schemas.xmlsoap.org/soap/encoding/\" base=\"q1:Array\">{0}" +
  635. " <xs:attribute d5p1:arrayType=\"xs:anyType[]\" ref=\"q1:arrayType\" xmlns:d5p1=\"http://schemas.xmlsoap.org/wsdl/\" />{0}" +
  636. " </xs:restriction>{0}" +
  637. " </xs:complexContent>{0}" +
  638. " </xs:complexType>{0}" +
  639. " <xs:complexType name=\"SimpleClass\">{0}" +
  640. " <xs:sequence>{0}" +
  641. #if NET_2_0
  642. " <xs:element minOccurs=\"0\" maxOccurs=\"1\" form=\"unqualified\" name=\"something\" type=\"xs:string\" />{0}" +
  643. #else
  644. " <xs:element minOccurs=\"1\" maxOccurs=\"1\" name=\"something\" type=\"xs:string\" />{0}" +
  645. #endif
  646. " </xs:sequence>{0}" +
  647. " </xs:complexType>{0}" +
  648. " <xs:complexType name=\"ArrayOfString\">{0}" +
  649. " <xs:complexContent mixed=\"false\">{0}" +
  650. " <xs:restriction xmlns:q2=\"http://schemas.xmlsoap.org/soap/encoding/\" base=\"q2:Array\">{0}" +
  651. " <xs:attribute d5p1:arrayType=\"xs:string[]\" ref=\"q2:arrayType\" xmlns:d5p1=\"http://schemas.xmlsoap.org/wsdl/\" />{0}" +
  652. " </xs:restriction>{0}" +
  653. " </xs:complexContent>{0}" +
  654. " </xs:complexType>{0}" +
  655. "</xs:schema>", Environment.NewLine), sw.ToString (), "#2");
  656. }
  657. [Test]
  658. [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
  659. public void ExportClass_ClsPerson ()
  660. {
  661. XmlSchemas schemas = Export (typeof (clsPerson), "NSClsPerson");
  662. Assert.AreEqual (1, schemas.Count, "#1");
  663. StringWriter sw = new StringWriter ();
  664. schemas[0].Write (sw);
  665. Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
  666. "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
  667. #if NET_2_0
  668. "<xs:schema xmlns:tns=\"NSClsPerson\" elementFormDefault=\"qualified\" targetNamespace=\"NSClsPerson\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
  669. #else
  670. "<xs:schema xmlns:tns=\"NSClsPerson\" targetNamespace=\"NSClsPerson\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
  671. #endif
  672. " <xs:import namespace=\"http://schemas.xmlsoap.org/soap/encoding/\" />{0}" +
  673. " <xs:import namespace=\"http://schemas.xmlsoap.org/wsdl/\" />{0}" +
  674. " <xs:complexType name=\"clsPerson\">{0}" +
  675. " <xs:sequence>{0}" +
  676. #if NET_2_0
  677. " <xs:element minOccurs=\"0\" maxOccurs=\"1\" form=\"unqualified\" name=\"EmailAccounts\" type=\"tns:ArrayOfAnyType\" />{0}" +
  678. #else
  679. " <xs:element minOccurs=\"1\" maxOccurs=\"1\" name=\"EmailAccounts\" type=\"tns:ArrayOfAnyType\" />{0}" +
  680. #endif
  681. " </xs:sequence>{0}" +
  682. " </xs:complexType>{0}" +
  683. " <xs:complexType name=\"ArrayOfAnyType\">{0}" +
  684. " <xs:complexContent mixed=\"false\">{0}" +
  685. " <xs:restriction xmlns:q1=\"http://schemas.xmlsoap.org/soap/encoding/\" base=\"q1:Array\">{0}" +
  686. " <xs:attribute d5p1:arrayType=\"xs:anyType[]\" ref=\"q1:arrayType\" xmlns:d5p1=\"http://schemas.xmlsoap.org/wsdl/\" />{0}" +
  687. " </xs:restriction>{0}" +
  688. " </xs:complexContent>{0}" +
  689. " </xs:complexType>{0}" +
  690. "</xs:schema>", Environment.NewLine), sw.ToString (), "#2");
  691. }
  692. [Test]
  693. [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
  694. public void ExportClass_ArrayClass ()
  695. {
  696. XmlSchemas schemas = Export (typeof (ArrayClass), "NSArrayClass");
  697. Assert.AreEqual (1, schemas.Count, "#1");
  698. StringWriter sw = new StringWriter ();
  699. schemas[0].Write (sw);
  700. Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
  701. "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
  702. #if NET_2_0
  703. "<xs:schema xmlns:tns=\"NSArrayClass\" elementFormDefault=\"qualified\" targetNamespace=\"NSArrayClass\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
  704. #else
  705. "<xs:schema xmlns:tns=\"NSArrayClass\" targetNamespace=\"NSArrayClass\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
  706. #endif
  707. " <xs:complexType name=\"ArrayClass\">{0}" +
  708. " <xs:sequence>{0}" +
  709. #if NET_2_0
  710. " <xs:element minOccurs=\"0\" maxOccurs=\"1\" form=\"unqualified\" name=\"names\" type=\"xs:anyType\" />{0}" +
  711. #else
  712. " <xs:element minOccurs=\"1\" maxOccurs=\"1\" name=\"names\" type=\"xs:anyType\" />{0}" +
  713. #endif
  714. " </xs:sequence>{0}" +
  715. " </xs:complexType>{0}" +
  716. "</xs:schema>", Environment.NewLine), sw.ToString (), "#4");
  717. }
  718. [Test]
  719. [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
  720. public void ExportClass_StructContainer ()
  721. {
  722. XmlSchemas schemas = Export (typeof (StructContainer), "NSStructContainer");
  723. Assert.AreEqual (1, schemas.Count, "#1");
  724. StringWriter sw = new StringWriter ();
  725. schemas[0].Write (sw);
  726. Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
  727. "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
  728. #if NET_2_0
  729. "<xs:schema xmlns:tns=\"NSStructContainer\" elementFormDefault=\"qualified\" targetNamespace=\"NSStructContainer\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
  730. #else
  731. "<xs:schema xmlns:tns=\"NSStructContainer\" targetNamespace=\"NSStructContainer\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
  732. #endif
  733. " <xs:complexType name=\"StructContainer\">{0}" +
  734. " <xs:sequence>{0}" +
  735. #if NET_2_0
  736. " <xs:element minOccurs=\"1\" maxOccurs=\"1\" form=\"unqualified\" name=\"Value\" type=\"tns:EnumDefaultValue\" />{0}" +
  737. #else
  738. " <xs:element minOccurs=\"1\" maxOccurs=\"1\" name=\"Value\" type=\"tns:EnumDefaultValue\" />{0}" +
  739. #endif
  740. " </xs:sequence>{0}" +
  741. " </xs:complexType>{0}" +
  742. " <xs:simpleType name=\"EnumDefaultValue\">{0}" +
  743. " <xs:list>{0}" +
  744. " <xs:simpleType>{0}" +
  745. " <xs:restriction base=\"xs:string\">{0}" +
  746. " <xs:enumeration value=\"e1\" />{0}" +
  747. " <xs:enumeration value=\"e2\" />{0}" +
  748. " <xs:enumeration value=\"e3\" />{0}" +
  749. " </xs:restriction>{0}" +
  750. " </xs:simpleType>{0}" +
  751. " </xs:list>{0}" +
  752. " </xs:simpleType>{0}" +
  753. "</xs:schema>", Environment.NewLine), sw.ToString (), "#2");
  754. }
  755. [Test]
  756. [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
  757. /*
  758. #if NET_2_0
  759. [Category ("NotWorking")] // minOccurs is 1 on Mono
  760. #endif
  761. */
  762. public void ExportClass_SimpleClass_Array ()
  763. {
  764. SoapAttributeOverrides overrides = new SoapAttributeOverrides ();
  765. SoapAttributes attr = new SoapAttributes ();
  766. SoapElementAttribute element = new SoapElementAttribute ();
  767. element.ElementName = "saying";
  768. element.IsNullable = true;
  769. attr.SoapElement = element;
  770. overrides.Add (typeof (SimpleClass), "something", attr);
  771. SoapReflectionImporter ri = new SoapReflectionImporter (overrides, "NSSimpleClassArray");
  772. XmlSchemas schemas = new XmlSchemas ();
  773. SoapSchemaExporter sx = new SoapSchemaExporter (schemas);
  774. XmlTypeMapping tm = ri.ImportTypeMapping (typeof (SimpleClass[]));
  775. sx.ExportTypeMapping (tm);
  776. Assert.AreEqual (1, schemas.Count, "#1");
  777. StringWriter sw = new StringWriter ();
  778. schemas[0].Write (sw);
  779. Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
  780. "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
  781. #if NET_2_0
  782. "<xs:schema xmlns:tns=\"NSSimpleClassArray\" elementFormDefault=\"qualified\" targetNamespace=\"NSSimpleClassArray\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
  783. #else
  784. "<xs:schema xmlns:tns=\"NSSimpleClassArray\" targetNamespace=\"NSSimpleClassArray\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
  785. #endif
  786. " <xs:import namespace=\"http://schemas.xmlsoap.org/soap/encoding/\" />{0}" +
  787. " <xs:import namespace=\"http://schemas.xmlsoap.org/wsdl/\" />{0}" +
  788. " <xs:complexType name=\"ArrayOfSimpleClass\">{0}" +
  789. " <xs:complexContent mixed=\"false\">{0}" +
  790. " <xs:restriction xmlns:q1=\"http://schemas.xmlsoap.org/soap/encoding/\" base=\"q1:Array\">{0}" +
  791. " <xs:attribute d5p1:arrayType=\"tns:SimpleClass[]\" ref=\"q1:arrayType\" xmlns:d5p1=\"http://schemas.xmlsoap.org/wsdl/\" />{0}" +
  792. " </xs:restriction>{0}" +
  793. " </xs:complexContent>{0}" +
  794. " </xs:complexType>{0}" +
  795. " <xs:complexType name=\"SimpleClass\">{0}" +
  796. " <xs:sequence>{0}" +
  797. #if NET_2_0
  798. " <xs:element minOccurs=\"0\" maxOccurs=\"1\" form=\"unqualified\" name=\"saying\" nillable=\"true\" type=\"xs:string\" />{0}" +
  799. #else
  800. " <xs:element minOccurs=\"1\" maxOccurs=\"1\" name=\"saying\" type=\"xs:string\" />{0}" +
  801. #endif
  802. " </xs:sequence>{0}" +
  803. " </xs:complexType>{0}" +
  804. "</xs:schema>", Environment.NewLine), sw.ToString (), "#2");
  805. }
  806. [Test]
  807. [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
  808. public void ExportEnum ()
  809. {
  810. XmlSchemas schemas = Export (typeof (EnumDefaultValue), "NSEnumDefaultValue");
  811. Assert.AreEqual (1, schemas.Count, "#1");
  812. StringWriter sw = new StringWriter ();
  813. schemas[0].Write (sw);
  814. Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
  815. "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
  816. #if NET_2_0
  817. "<xs:schema xmlns:tns=\"NSEnumDefaultValue\" elementFormDefault=\"qualified\" targetNamespace=\"NSEnumDefaultValue\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
  818. #else
  819. "<xs:schema xmlns:tns=\"NSEnumDefaultValue\" targetNamespace=\"NSEnumDefaultValue\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
  820. #endif
  821. " <xs:simpleType name=\"EnumDefaultValue\">{0}" +
  822. " <xs:list>{0}" +
  823. " <xs:simpleType>{0}" +
  824. " <xs:restriction base=\"xs:string\">{0}" +
  825. " <xs:enumeration value=\"e1\" />{0}" +
  826. " <xs:enumeration value=\"e2\" />{0}" +
  827. " <xs:enumeration value=\"e3\" />{0}" +
  828. " </xs:restriction>{0}" +
  829. " </xs:simpleType>{0}" +
  830. " </xs:list>{0}" +
  831. " </xs:simpleType>{0}" +
  832. "</xs:schema>", Environment.NewLine), sw.ToString (), "#2");
  833. schemas = Export (typeof (EnumDefaultValueNF), "NSEnumDefaultValueNF");
  834. Assert.AreEqual (1, schemas.Count, "#3");
  835. sw = new StringWriter ();
  836. schemas[0].Write (sw);
  837. Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
  838. "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
  839. #if NET_2_0
  840. "<xs:schema xmlns:tns=\"NSEnumDefaultValueNF\" elementFormDefault=\"qualified\" targetNamespace=\"NSEnumDefaultValueNF\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
  841. #else
  842. "<xs:schema xmlns:tns=\"NSEnumDefaultValueNF\" targetNamespace=\"NSEnumDefaultValueNF\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
  843. #endif
  844. " <xs:simpleType name=\"EnumDefaultValueNF\">{0}" +
  845. " <xs:restriction base=\"xs:string\">{0}" +
  846. " <xs:enumeration value=\"e1\" />{0}" +
  847. " <xs:enumeration value=\"e2\" />{0}" +
  848. " <xs:enumeration value=\"e3\" />{0}" +
  849. " </xs:restriction>{0}" +
  850. " </xs:simpleType>{0}" +
  851. "</xs:schema>", Environment.NewLine), sw.ToString (), "#4");
  852. }
  853. [Test]
  854. [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
  855. public void ExportXsdPrimitive ()
  856. {
  857. ArrayList types = new ArrayList ();
  858. types.Add (new TypeDescription (typeof (object), true, "anyType", "Object"));
  859. types.Add (new TypeDescription (typeof (byte), true, "unsignedByte", "Byte"));
  860. types.Add (new TypeDescription (typeof (sbyte), true, "byte", "Byte"));
  861. types.Add (new TypeDescription (typeof (bool), true, "boolean", "Boolean"));
  862. types.Add (new TypeDescription (typeof (short), true, "short", "Short"));
  863. types.Add (new TypeDescription (typeof (int), true, "int", "Int"));
  864. types.Add (new TypeDescription (typeof (long), true, "long", "Long"));
  865. types.Add (new TypeDescription (typeof (float), true, "float", "Float"));
  866. types.Add (new TypeDescription (typeof (double), true, "double", "Double"));
  867. types.Add (new TypeDescription (typeof (decimal), true, "decimal", "Decimal"));
  868. types.Add (new TypeDescription (typeof (ushort), true, "unsignedShort", "UnsignedShort"));
  869. types.Add (new TypeDescription (typeof (uint), true, "unsignedInt", "UnsignedInt"));
  870. types.Add (new TypeDescription (typeof (ulong), true, "unsignedLong", "UnsignedLong"));
  871. types.Add (new TypeDescription (typeof (DateTime), true, "dateTime", "DateTime"));
  872. #if NET_2_0
  873. types.Add (new TypeDescription (typeof (XmlQualifiedName), true, "QName", "QName", true));
  874. #else
  875. types.Add (new TypeDescription (typeof (XmlQualifiedName), true, "QName", "QName"));
  876. #endif
  877. types.Add (new TypeDescription (typeof (string), true, "string", "String", true));
  878. foreach (TypeDescription typeDesc in types) {
  879. XmlSchemas schemas = Export (typeDesc.Type, typeDesc.Type.Name);
  880. Assert.AreEqual (0, schemas.Count, typeDesc.Type.FullName + "#1");
  881. }
  882. }
  883. [Test]
  884. [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
  885. public void ExportXsdPrimitive_ByteArray ()
  886. {
  887. XmlSchemas schemas = Export (typeof (byte[]), "ByteArray");
  888. Assert.AreEqual (0, schemas.Count, "#1");
  889. }
  890. [Test]
  891. [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
  892. public void ExportXsdPrimitive_Arrays ()
  893. {
  894. ArrayList types = new ArrayList ();
  895. types.Add (new TypeDescription (typeof (object[]), true, "anyType", "AnyType"));
  896. types.Add (new TypeDescription (typeof (sbyte[]), true, "byte", "Byte"));
  897. types.Add (new TypeDescription (typeof (bool[]), true, "boolean", "Boolean"));
  898. types.Add (new TypeDescription (typeof (short[]), true, "short", "Short"));
  899. types.Add (new TypeDescription (typeof (int[]), true, "int", "Int"));
  900. types.Add (new TypeDescription (typeof (long[]), true, "long", "Long"));
  901. types.Add (new TypeDescription (typeof (float[]), true, "float", "Float"));
  902. types.Add (new TypeDescription (typeof (double[]), true, "double", "Double"));
  903. types.Add (new TypeDescription (typeof (decimal[]), true, "decimal", "Decimal"));
  904. types.Add (new TypeDescription (typeof (ushort[]), true, "unsignedShort", "UnsignedShort"));
  905. types.Add (new TypeDescription (typeof (uint[]), true, "unsignedInt", "UnsignedInt"));
  906. types.Add (new TypeDescription (typeof (ulong[]), true, "unsignedLong", "UnsignedLong"));
  907. types.Add (new TypeDescription (typeof (DateTime[]), true, "dateTime", "DateTime"));
  908. #if NET_2_0
  909. types.Add (new TypeDescription (typeof (XmlQualifiedName[]), true, "QName", "QName", true));
  910. #else
  911. types.Add (new TypeDescription (typeof (XmlQualifiedName[]), true, "QName", "QName"));
  912. #endif
  913. types.Add (new TypeDescription (typeof (string[]), true, "string", "String", true));
  914. foreach (TypeDescription typeDesc in types) {
  915. XmlSchemas schemas = Export (typeDesc.Type, typeDesc.Type.Name);
  916. Assert.AreEqual (1, schemas.Count, typeDesc.Type.FullName + "#1");
  917. StringWriter sw = new StringWriter ();
  918. schemas[0].Write (sw);
  919. Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
  920. "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
  921. #if NET_2_0
  922. "<xs:schema xmlns:tns=\"{1}\" elementFormDefault=\"qualified\" targetNamespace=\"{1}\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
  923. #else
  924. "<xs:schema xmlns:tns=\"{1}\" targetNamespace=\"{1}\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
  925. #endif
  926. " <xs:import namespace=\"http://schemas.xmlsoap.org/soap/encoding/\" />{0}" +
  927. " <xs:import namespace=\"http://schemas.xmlsoap.org/wsdl/\" />{0}" +
  928. " <xs:complexType name=\"ArrayOf{2}\">{0}" +
  929. " <xs:complexContent mixed=\"false\">{0}" +
  930. " <xs:restriction xmlns:q1=\"http://schemas.xmlsoap.org/soap/encoding/\" base=\"q1:Array\">{0}" +
  931. " <xs:attribute d5p1:arrayType=\"xs:{3}[]\" ref=\"q1:arrayType\" xmlns:d5p1=\"http://schemas.xmlsoap.org/wsdl/\" />{0}" +
  932. " </xs:restriction>{0}" +
  933. " </xs:complexContent>{0}" +
  934. " </xs:complexType>{0}" +
  935. "</xs:schema>", Environment.NewLine, typeDesc.Type.Name, typeDesc.ArrayType, typeDesc.XmlType,
  936. typeDesc.XsdType ? "xs" : "tns", typeDesc.IsNillable ? "nillable=\"true\" " : ""),
  937. sw.ToString (), typeDesc.Type.FullName + "#2");
  938. }
  939. }
  940. [Test]
  941. [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
  942. public void ExportNonXsdPrimitive_Guid ()
  943. {
  944. XmlSchemas schemas = Export (typeof (Guid), "NSPrimGuid");
  945. Assert.AreEqual (1, schemas.Count, "#1");
  946. StringWriter sw = new StringWriter ();
  947. schemas[0].Write (sw);
  948. Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
  949. "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
  950. #if NET_2_0
  951. "<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}" +
  952. #else
  953. "<xs:schema xmlns:tns=\"http://microsoft.com/wsdl/types/\" targetNamespace=\"http://microsoft.com/wsdl/types/\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
  954. #endif
  955. " <xs:simpleType name=\"guid\">{0}" +
  956. " <xs:restriction base=\"xs:string\">{0}" +
  957. " <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}" +
  958. " </xs:restriction>{0}" +
  959. " </xs:simpleType>{0}" +
  960. "</xs:schema>", Environment.NewLine), sw.ToString (), "#2");
  961. }
  962. [Test]
  963. [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
  964. public void ExportNonXsdPrimitive_Char ()
  965. {
  966. XmlSchemas schemas = Export (typeof (Char), "NSPrimChar");
  967. Assert.AreEqual (1, schemas.Count, "#1");
  968. StringWriter sw = new StringWriter ();
  969. schemas[0].Write (sw);
  970. Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
  971. "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
  972. #if NET_2_0
  973. "<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}" +
  974. #else
  975. "<xs:schema xmlns:tns=\"http://microsoft.com/wsdl/types/\" targetNamespace=\"http://microsoft.com/wsdl/types/\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
  976. #endif
  977. " <xs:simpleType name=\"char\">{0}" +
  978. " <xs:restriction base=\"xs:unsignedShort\" />{0}" +
  979. " </xs:simpleType>{0}" +
  980. "</xs:schema>", Environment.NewLine), sw.ToString (), "#2");
  981. }
  982. public class Employee : IXmlSerializable
  983. {
  984. private string _firstName;
  985. private string _lastName;
  986. private string _address;
  987. public XmlSchema GetSchema ()
  988. {
  989. return null;
  990. }
  991. public void WriteXml (XmlWriter writer)
  992. {
  993. writer.WriteStartElement ("employee", "urn:devx-com");
  994. writer.WriteAttributeString ("firstName", _firstName);
  995. writer.WriteAttributeString ("lastName", _lastName);
  996. writer.WriteAttributeString ("address", _address);
  997. writer.WriteEndElement ();
  998. }
  999. public void ReadXml (XmlReader reader)
  1000. {
  1001. XmlNodeType type = reader.MoveToContent ();
  1002. if (type == XmlNodeType.Element && reader.LocalName == "employee") {
  1003. _firstName = reader["firstName"];
  1004. _lastName = reader["lastName"];
  1005. _address = reader["address"];
  1006. }
  1007. }
  1008. }
  1009. public class StructContainer
  1010. {
  1011. public EnumDefaultValue Value;
  1012. }
  1013. private class TypeDescription
  1014. {
  1015. public TypeDescription (Type type, bool xsdType, string xmlType, string arrayType)
  1016. : this (type, xsdType, xmlType, arrayType, false)
  1017. {
  1018. }
  1019. public TypeDescription (Type type, bool xsdType, string xmlType, string arrayType, bool isNillable)
  1020. {
  1021. _type = type;
  1022. _xsdType = xsdType;
  1023. _xmlType = xmlType;
  1024. _arrayType = arrayType;
  1025. _isNillable = isNillable;
  1026. }
  1027. public Type Type
  1028. {
  1029. get { return _type; }
  1030. }
  1031. public string XmlType
  1032. {
  1033. get { return _xmlType; }
  1034. }
  1035. public string ArrayType
  1036. {
  1037. get { return _arrayType; }
  1038. }
  1039. public bool XsdType
  1040. {
  1041. get { return _xsdType; }
  1042. }
  1043. public bool IsNillable
  1044. {
  1045. get { return _isNillable; }
  1046. }
  1047. private Type _type;
  1048. private bool _xsdType;
  1049. private string _xmlType;
  1050. private string _arrayType;
  1051. private bool _isNillable;
  1052. }
  1053. }
  1054. }
  1055. #endif