XmlSerializerTestClasses.cs 17 KB

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