XmlSerializerTestClasses.cs 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870
  1. //
  2. // System.Xml.XmlSerializerTestClasses
  3. //
  4. // Authors:
  5. // Erik LeBel <[email protected]>
  6. // Hagit Yidov <[email protected]>
  7. //
  8. // (C) 2003 Erik LeBel
  9. // (C) 2005 Mainsoft Corporation (http://www.mainsoft.com)
  10. //
  11. // Classes to use in the testing of the XmlSerializer
  12. //
  13. using System;
  14. using System.ComponentModel;
  15. using System.Collections;
  16. using System.Xml;
  17. using System.Xml.Schema;
  18. using System.Xml.Serialization;
  19. using System.Collections.Generic;
  20. namespace MonoTests.System.Xml.TestClasses
  21. {
  22. public enum SimpleEnumeration { FIRST, SECOND };
  23. [Flags]
  24. public enum EnumDefaultValue { e1 = 1, e2 = 2, e3 = 3 }
  25. public enum EnumDefaultValueNF { e1 = 1, e2 = 2, e3 = 3 }
  26. [Flags]
  27. public enum FlagEnum
  28. {
  29. [XmlEnum ("one")]
  30. e1 = 1,
  31. [XmlEnum ("two")]
  32. e2 = 2,
  33. [XmlEnum ("four")]
  34. e4 = 4
  35. }
  36. [Flags]
  37. [SoapType ("flagenum")]
  38. public enum FlagEnum_Encoded
  39. {
  40. [SoapEnum ("one")]
  41. e1 = 1,
  42. [SoapEnum ("two")]
  43. e2 = 2,
  44. [SoapEnum ("four")]
  45. e4 = 4
  46. }
  47. [Flags]
  48. public enum ZeroFlagEnum
  49. {
  50. [XmlEnum ("zero")]
  51. e0 = 0,
  52. [XmlEnum ("o<n>e")]
  53. e1 = 1,
  54. [XmlEnum ("tns:t<w>o")]
  55. e2 = 2,
  56. [XmlEnum ("four")]
  57. [XmlIgnore]
  58. e4 = 4
  59. }
  60. #region GenericsTestClasses
  61. public class GenSimpleClass<T>
  62. {
  63. public T something = default (T);
  64. }
  65. public struct GenSimpleStruct<T>
  66. {
  67. public T something;
  68. public GenSimpleStruct (int dummy)
  69. {
  70. something = default (T);
  71. }
  72. }
  73. public class GenListClass<T>
  74. {
  75. public List<T> somelist = new List<T> ();
  76. }
  77. public class GenArrayClass<T>
  78. {
  79. public T[] arr = new T[3];
  80. }
  81. public class GenTwoClass<T1, T2>
  82. {
  83. public T1 something1 = default (T1);
  84. public T2 something2 = default (T2);
  85. }
  86. public class GenDerivedClass<T1, T2> : GenTwoClass<string, int>
  87. {
  88. public T1 another1 = default (T1);
  89. public T2 another2 = default (T2);
  90. }
  91. public class GenDerived2Class<T1, T2> : GenTwoClass<T1, T2>
  92. {
  93. public T1 another1 = default (T1);
  94. public T2 another2 = default (T2);
  95. }
  96. public class GenNestedClass<TO, TI>
  97. {
  98. public TO outer = default (TO);
  99. public class InnerClass<T>
  100. {
  101. public TI inner = default (TI);
  102. public T something = default (T);
  103. }
  104. }
  105. public struct GenComplexStruct<T1, T2>
  106. {
  107. public T1 something;
  108. public GenSimpleClass<T1> simpleclass;
  109. public GenSimpleStruct<T1> simplestruct;
  110. public GenListClass<T1> listclass;
  111. public GenArrayClass<T1> arrayclass;
  112. public GenTwoClass<T1, T2> twoclass;
  113. public GenDerivedClass<T1, T2> derivedclass;
  114. public GenDerived2Class<T1, T2> derived2;
  115. public GenNestedClass<T1, T2> nestedouter;
  116. public GenNestedClass<T1, T2>.InnerClass<T1> nestedinner;
  117. public GenComplexStruct (int dummy)
  118. {
  119. something = default (T1);
  120. simpleclass = new GenSimpleClass<T1> ();
  121. simplestruct = new GenSimpleStruct<T1> ();
  122. listclass = new GenListClass<T1> ();
  123. arrayclass = new GenArrayClass<T1> ();
  124. twoclass = new GenTwoClass<T1, T2> ();
  125. derivedclass = new GenDerivedClass<T1, T2> ();
  126. derived2 = new GenDerived2Class<T1, T2> ();
  127. nestedouter = new GenNestedClass<T1, T2> ();
  128. nestedinner = new GenNestedClass<T1, T2>.InnerClass<T1> ();
  129. }
  130. }
  131. #endregion // GenericsTestClasses
  132. public class SimpleClass
  133. {
  134. public string something = null;
  135. }
  136. public class StringCollection : CollectionBase
  137. {
  138. public void Add (String parameter)
  139. {
  140. List.Insert (Count, parameter);
  141. }
  142. public String this[int index]
  143. {
  144. get
  145. {
  146. if (index < 0 || index > Count)
  147. throw new ArgumentOutOfRangeException ();
  148. return (String) List[index];
  149. }
  150. set { List[index] = value; }
  151. }
  152. }
  153. public class StringCollectionContainer
  154. {
  155. StringCollection messages = new StringCollection ();
  156. public StringCollection Messages
  157. {
  158. get { return messages; }
  159. }
  160. }
  161. public class ArrayContainer
  162. {
  163. public object[] items = null;
  164. }
  165. public class ClassArrayContainer
  166. {
  167. public SimpleClass[] items = null;
  168. }
  169. [XmlRoot ("simple")]
  170. public class SimpleClassWithXmlAttributes
  171. {
  172. [XmlAttribute ("member")]
  173. public string something = null;
  174. }
  175. [XmlRoot ("field")]
  176. public class Field
  177. {
  178. [XmlAttribute ("flag1")]
  179. [DefaultValue (1)]
  180. public FlagEnum Flags1;
  181. [XmlAttribute ("flag2")]
  182. [DefaultValue (FlagEnum.e1)]
  183. public FlagEnum Flags2;
  184. [XmlAttribute ("flag3", Form = XmlSchemaForm.Qualified)]
  185. [DefaultValue (FlagEnum.e1 | FlagEnum.e2)]
  186. public FlagEnum Flags3;
  187. [XmlAttribute ("flag4")]
  188. public FlagEnum Flags4;
  189. [XmlAttribute ("modifiers")]
  190. public MapModifiers Modifiers;
  191. [XmlAttribute ("modifiers2", Form = XmlSchemaForm.Unqualified)]
  192. public MapModifiers Modifiers2;
  193. [XmlAttribute ("modifiers3")]
  194. [DefaultValue (0)]
  195. public MapModifiers Modifiers3;
  196. [XmlAttribute ("modifiers4", Form = XmlSchemaForm.Unqualified)]
  197. [DefaultValue (MapModifiers.Protected)]
  198. public MapModifiers Modifiers4;
  199. [XmlAttribute ("modifiers5", Form = XmlSchemaForm.Qualified)]
  200. [DefaultValue (MapModifiers.Public)]
  201. public MapModifiers Modifiers5;
  202. [XmlAttribute ("names")]
  203. public string[] Names;
  204. [XmlAttribute ("street")]
  205. public string Street;
  206. }
  207. [SoapType ("field", Namespace = "some:urn")]
  208. public class Field_Encoded
  209. {
  210. [SoapAttribute ("flag1")]
  211. [DefaultValue (FlagEnum_Encoded.e1)]
  212. public FlagEnum_Encoded Flags1;
  213. [SoapAttribute ("flag2")]
  214. [DefaultValue (FlagEnum_Encoded.e1)]
  215. public FlagEnum_Encoded Flags2;
  216. [SoapAttribute ("flag3")]
  217. [DefaultValue (FlagEnum_Encoded.e1 | FlagEnum_Encoded.e2)]
  218. public FlagEnum_Encoded Flags3;
  219. [SoapAttribute ("flag4")]
  220. public FlagEnum_Encoded Flags4;
  221. [SoapAttribute ("modifiers")]
  222. public MapModifiers Modifiers;
  223. [SoapAttribute ("modifiers2")]
  224. public MapModifiers Modifiers2;
  225. [SoapAttribute ("modifiers3")]
  226. [DefaultValue (MapModifiers.Public)]
  227. public MapModifiers Modifiers3;
  228. [SoapAttribute ("modifiers4")]
  229. [DefaultValue (MapModifiers.Protected)]
  230. public MapModifiers Modifiers4;
  231. [SoapAttribute ("modifiers5")]
  232. [DefaultValue (MapModifiers.Public)]
  233. public MapModifiers Modifiers5;
  234. public string[] Names;
  235. [SoapAttribute ("street")]
  236. public string Street;
  237. }
  238. [Flags]
  239. public enum MapModifiers
  240. {
  241. [XmlEnum ("public")]
  242. [SoapEnum ("PuBlIc")]
  243. Public = 0,
  244. [XmlEnum ("protected")]
  245. Protected = 1,
  246. }
  247. public class MyList : ArrayList
  248. {
  249. object container;
  250. // NOTE: MyList has no public constructor
  251. public MyList (object container)
  252. : base ()
  253. {
  254. this.container = container;
  255. }
  256. }
  257. public class Container
  258. {
  259. public MyList Items;
  260. public Container ()
  261. {
  262. Items = new MyList (this);
  263. }
  264. }
  265. public class Container2
  266. {
  267. public MyList Items;
  268. public Container2 ()
  269. {
  270. }
  271. public Container2 (bool b)
  272. {
  273. Items = new MyList (this);
  274. }
  275. }
  276. public class MyElem : XmlElement
  277. {
  278. public MyElem (XmlDocument doc)
  279. : base ("", "myelem", "", doc)
  280. {
  281. SetAttribute ("aa", "1");
  282. }
  283. [XmlAttribute]
  284. public int kk = 1;
  285. }
  286. public class MyDocument : XmlDocument
  287. {
  288. public MyDocument ()
  289. {
  290. }
  291. [XmlAttribute]
  292. public int kk = 1;
  293. }
  294. public class CDataContainer
  295. {
  296. public XmlCDataSection cdata;
  297. }
  298. public class NodeContainer
  299. {
  300. public XmlNode node;
  301. }
  302. public class Choices
  303. {
  304. [XmlElementAttribute ("ChoiceZero", typeof (string), IsNullable = false)]
  305. [XmlElementAttribute ("ChoiceOne", typeof (string), IsNullable = false)]
  306. [XmlElementAttribute ("ChoiceTwo", typeof (string), IsNullable = false)]
  307. [XmlChoiceIdentifier ("ItemType")]
  308. public string MyChoice;
  309. [XmlIgnore]
  310. public ItemChoiceType ItemType;
  311. }
  312. [XmlType (IncludeInSchema = false)]
  313. public enum ItemChoiceType
  314. {
  315. ChoiceZero,
  316. [XmlEnum ("ChoiceOne")]
  317. StrangeOne,
  318. ChoiceTwo,
  319. }
  320. public class WrongChoices
  321. {
  322. [XmlElementAttribute ("ChoiceZero", typeof (string), IsNullable = false)]
  323. [XmlElementAttribute ("StrangeOne", typeof (string), IsNullable = false)]
  324. [XmlElementAttribute ("ChoiceTwo", typeof (string), IsNullable = false)]
  325. [XmlChoiceIdentifier ("ItemType")]
  326. public string MyChoice;
  327. [XmlIgnore]
  328. public ItemChoiceType ItemType;
  329. }
  330. [XmlType ("Type with space")]
  331. public class TestSpace
  332. {
  333. [XmlElement (ElementName = "Element with space")]
  334. public int elem;
  335. [XmlAttribute (AttributeName = "Attribute with space")]
  336. public int attr;
  337. }
  338. [Serializable]
  339. public class ReadOnlyProperties
  340. {
  341. string[] strArr = new string[2] { "string1", "string2" };
  342. public string[] StrArr
  343. {
  344. get { return strArr; }
  345. }
  346. public string dat
  347. {
  348. get { return "fff"; }
  349. }
  350. }
  351. [XmlRoot ("root")]
  352. public class ListDefaults
  353. {
  354. public ListDefaults ()
  355. {
  356. ed = new SimpleClass ();
  357. str = "hola";
  358. }
  359. public ArrayList list2;
  360. public MyList list3;
  361. public string[] list4;
  362. [XmlElement ("e", typeof (SimpleClass))]
  363. public ArrayList list5;
  364. [DefaultValue (null)]
  365. public SimpleClass ed;
  366. [DefaultValue (null)]
  367. public string str;
  368. }
  369. public class clsPerson
  370. {
  371. public IList EmailAccounts;
  372. }
  373. public class ArrayClass
  374. {
  375. public object names = new object[] { "un", "dos" };
  376. }
  377. public class CompositeValueType
  378. {
  379. public void Init ()
  380. {
  381. Items = new object[] { 1, 2 };
  382. ItemsElementName = new ItemsChoiceType[] { ItemsChoiceType.In, ItemsChoiceType.Es };
  383. }
  384. [XmlElementAttribute ("Es", typeof (int))]
  385. [XmlElementAttribute ("In", typeof (int))]
  386. [XmlChoiceIdentifierAttribute ("ItemsElementName")]
  387. public object[] Items;
  388. [XmlElementAttribute ("ItemsElementName")]
  389. [XmlIgnoreAttribute ()]
  390. public ItemsChoiceType[] ItemsElementName;
  391. }
  392. public enum ItemsChoiceType
  393. {
  394. In, Es
  395. }
  396. public class ArrayAttributeWithType
  397. {
  398. [XmlAttribute (DataType = "anyURI")]
  399. public string[] at = new string[] { "a", "b" };
  400. [XmlAttribute (DataType = "base64Binary")]
  401. public byte[][] bin1 = new byte[][] { new byte[] { 1, 2 }, new byte[] { 1, 2 } };
  402. [XmlAttribute (DataType = "base64Binary")]
  403. public byte[] bin2 = new byte[] { 1, 2 };
  404. }
  405. public class ArrayAttributeWithWrongType
  406. {
  407. [XmlAttribute (DataType = "int")]
  408. public string[] at = new string[] { "a", "b" };
  409. }
  410. [XmlType ("Container")]
  411. public class EntityContainer
  412. {
  413. EntityCollection collection1;
  414. EntityCollection collection2;
  415. EntityCollection collection3 = new EntityCollection ("root");
  416. EntityCollection collection4 = new EntityCollection ("root");
  417. [XmlArray (IsNullable = true)]
  418. public EntityCollection Collection1
  419. {
  420. get { return collection1; }
  421. set { collection1 = value; collection1.Container = "assigned"; }
  422. }
  423. [XmlArray (IsNullable = false)]
  424. public EntityCollection Collection2
  425. {
  426. get { return collection2; }
  427. set { collection2 = value; collection2.Container = "assigned"; }
  428. }
  429. [XmlArray (IsNullable = true)]
  430. public EntityCollection Collection3
  431. {
  432. get { return collection3; }
  433. set { collection3 = value; collection3.Container = "assigned"; }
  434. }
  435. [XmlArray (IsNullable = false)]
  436. public EntityCollection Collection4
  437. {
  438. get { return collection4; }
  439. set { collection4 = value; collection4.Container = "assigned"; }
  440. }
  441. }
  442. [XmlType ("Container")]
  443. public class ArrayEntityContainer
  444. {
  445. Entity[] collection1;
  446. Entity[] collection2;
  447. Entity[] collection3 = new Entity[0];
  448. Entity[] collection4 = new Entity[0];
  449. [XmlArray (IsNullable = true)]
  450. public Entity[] Collection1
  451. {
  452. get { return collection1; }
  453. set { collection1 = value; }
  454. }
  455. [XmlArray (IsNullable = false)]
  456. public Entity[] Collection2
  457. {
  458. get { return collection2; }
  459. set { collection2 = value; }
  460. }
  461. [XmlArray (IsNullable = true)]
  462. public Entity[] Collection3
  463. {
  464. get { return collection3; }
  465. set { collection3 = value; }
  466. }
  467. [XmlArray (IsNullable = false)]
  468. public Entity[] Collection4
  469. {
  470. get { return collection4; }
  471. set { collection4 = value; }
  472. }
  473. }
  474. public class Entity
  475. {
  476. private string _name = string.Empty;
  477. private string _parent = null;
  478. [XmlAttribute]
  479. public string Name
  480. {
  481. get { return _name; }
  482. set { _name = value; }
  483. }
  484. [XmlIgnore]
  485. public string Parent
  486. {
  487. get { return _parent; }
  488. set { _parent = value; }
  489. }
  490. }
  491. public class EntityCollection : ArrayList
  492. {
  493. public string _container;
  494. public EntityCollection ()
  495. {
  496. }
  497. public EntityCollection (string c)
  498. {
  499. _container = c;
  500. }
  501. public string Container
  502. {
  503. get { return _container; }
  504. set { _container = value; }
  505. }
  506. public int Add (Entity value)
  507. {
  508. if (_container != null)
  509. value.Parent = _container;
  510. return base.Add (value);
  511. }
  512. public new Entity this[int index]
  513. {
  514. get { return (Entity) base[index]; }
  515. set { base[index] = value; }
  516. }
  517. }
  518. [XmlType ("Container")]
  519. public class ObjectWithReadonlyCollection
  520. {
  521. EntityCollection collection1 = new EntityCollection ("root");
  522. public EntityCollection Collection1
  523. {
  524. get { return collection1; }
  525. }
  526. }
  527. [XmlType ("Container")]
  528. public class ObjectWithReadonlyNulCollection
  529. {
  530. EntityCollection collection1;
  531. public EntityCollection Collection1
  532. {
  533. get { return collection1; }
  534. }
  535. }
  536. [XmlType ("Container")]
  537. public class ObjectWithReadonlyArray
  538. {
  539. Entity[] collection1 = new Entity[0];
  540. public Entity[] Collection1
  541. {
  542. get { return collection1; }
  543. }
  544. }
  545. [XmlInclude (typeof (SubclassTestSub))]
  546. public class SubclassTestBase
  547. {
  548. }
  549. public class SubclassTestSub : SubclassTestBase
  550. {
  551. }
  552. public class SubclassTestExtra
  553. {
  554. }
  555. public class SubclassTestContainer
  556. {
  557. [XmlElement ("a", typeof (SubclassTestBase))]
  558. [XmlElement ("b", typeof (SubclassTestExtra))]
  559. public object data;
  560. }
  561. public class DictionaryWithIndexer : DictionaryBase
  562. {
  563. public TimeSpan this[int index]
  564. {
  565. get { return TimeSpan.MinValue; }
  566. }
  567. public void Add (TimeSpan value)
  568. {
  569. }
  570. }
  571. [XmlRoot (Namespace = "some:urn")]
  572. [SoapTypeAttribute (Namespace = "another:urn")]
  573. public class PrimitiveTypesContainer
  574. {
  575. public PrimitiveTypesContainer ()
  576. {
  577. Number = 2004;
  578. Name = "some name";
  579. Index = (byte) 56;
  580. Password = new byte[] { 243, 15 };
  581. PathSeparatorCharacter = '/';
  582. }
  583. public int Number;
  584. public string Name;
  585. public byte Index;
  586. public byte[] Password;
  587. public char PathSeparatorCharacter;
  588. }
  589. public class TestSchemaForm1
  590. {
  591. public PrintTypeResponse p1;
  592. [XmlElement (Namespace = "urn:oo")]
  593. public PrintTypeResponse p2;
  594. }
  595. [XmlType (Namespace = "urn:testForm")]
  596. public class TestSchemaForm2
  597. {
  598. public PrintTypeResponse p1;
  599. [XmlElement (Namespace = "urn:oo")]
  600. public PrintTypeResponse p2;
  601. }
  602. [XmlType (Namespace = "urn:responseTypes")]
  603. public class PrintTypeResponse
  604. {
  605. [XmlElement (Form = XmlSchemaForm.Unqualified, IsNullable = true)]
  606. public OutputType result;
  607. public PrintTypeResponse intern;
  608. public void Init ()
  609. {
  610. result = new OutputType ();
  611. result.data = "data1";
  612. intern = new PrintTypeResponse ();
  613. intern.result = new OutputType ();
  614. intern.result.data = "data2";
  615. }
  616. }
  617. [XmlType (Namespace = "urn:responseTypes")]
  618. public class OutputType
  619. {
  620. [XmlElement (Form = XmlSchemaForm.Unqualified, IsNullable = true)]
  621. public string data;
  622. }
  623. [XmlRootAttribute ("testDefault", Namespace = "urn:myNS", IsNullable = false)]
  624. [SoapType ("testDefault", Namespace = "urn:myNS")]
  625. public class TestDefault
  626. {
  627. public string str;
  628. [DefaultValue ("Default Value")]
  629. public string strDefault = "Default Value";
  630. [DefaultValue (true)]
  631. public bool boolT = true;
  632. [DefaultValue (false)]
  633. public bool boolF = false;
  634. [DefaultValue (typeof (decimal), "10")]
  635. public decimal decimalval = 10m;
  636. [DefaultValue (FlagEnum.e1 | FlagEnum.e4)]
  637. public FlagEnum flag = (FlagEnum.e1 | FlagEnum.e4);
  638. [DefaultValue (FlagEnum_Encoded.e1 | FlagEnum_Encoded.e4)]
  639. public FlagEnum_Encoded flagencoded = (FlagEnum_Encoded.e1 | FlagEnum_Encoded.e4);
  640. }
  641. [XmlType ("optionalValueType", Namespace = "some:urn")]
  642. [XmlRootAttribute ("optionalValue", Namespace = "another:urn", IsNullable = false)]
  643. public class OptionalValueTypeContainer
  644. {
  645. [DefaultValue (FlagEnum.e1 | FlagEnum.e4)]
  646. public FlagEnum Attributes = FlagEnum.e1 | FlagEnum.e4;
  647. [DefaultValue (FlagEnum.e1)]
  648. public FlagEnum Flags = FlagEnum.e1;
  649. [XmlIgnore]
  650. [SoapIgnore]
  651. public bool FlagsSpecified;
  652. [DefaultValue (false)]
  653. public bool IsEmpty;
  654. [XmlIgnore]
  655. [SoapIgnore]
  656. public bool IsEmptySpecified
  657. {
  658. get { return _isEmptySpecified; }
  659. set { _isEmptySpecified = value; }
  660. }
  661. [DefaultValue (false)]
  662. public bool IsNull;
  663. private bool _isEmptySpecified;
  664. }
  665. public class Group
  666. {
  667. [SoapAttribute (Namespace = "http://www.cpandl.com")]
  668. public string GroupName;
  669. [SoapAttribute (DataType = "base64Binary")]
  670. public Byte[] GroupNumber;
  671. [SoapAttribute (DataType = "date", AttributeName = "CreationDate")]
  672. public DateTime Today;
  673. [SoapElement (DataType = "nonNegativeInteger", ElementName = "PosInt")]
  674. public string PostitiveInt;
  675. [SoapIgnore]
  676. public bool IgnoreThis;
  677. [DefaultValue (GroupType.B)]
  678. public GroupType Grouptype;
  679. public Vehicle MyVehicle;
  680. [SoapInclude (typeof (Car))]
  681. public Vehicle myCar (string licNumber)
  682. {
  683. Vehicle v;
  684. if (licNumber == string.Empty) {
  685. v = new Car ();
  686. v.licenseNumber = "!!!!!!";
  687. }
  688. else {
  689. v = new Car ();
  690. v.licenseNumber = licNumber;
  691. }
  692. return v;
  693. }
  694. }
  695. [SoapInclude (typeof (Car))]
  696. public abstract class Vehicle
  697. {
  698. public string licenseNumber;
  699. [SoapElement (DataType = "date")]
  700. public DateTime makeDate;
  701. [DefaultValue ("450")]
  702. public string weight;
  703. }
  704. public class Car : Vehicle
  705. {
  706. }
  707. public enum GroupType
  708. {
  709. [SoapEnum ("Small")]
  710. A,
  711. [SoapEnum ("Large")]
  712. B
  713. }
  714. }