XmlSerializerTestClasses.cs 17 KB

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