2005-04-12 Dick Porter <dick@ximian.com>
[mono.git] / mcs / class / System.XML / Test / System.Xml.Serialization / XmlSerializerTestClasses.cs
1 //\r
2 // System.Xml.XmlSerializerTestClasses\r
3 //\r
4 // Author:\r
5 //   Erik LeBel <eriklebel@yahoo.ca>\r
6 //\r
7 // (C) 2003 Erik LeBel\r
8 //\r
9 // Classes to use in the testing of the XmlSerializer\r
10 //\r
11 \r
12 using System;\r
13 using System.Collections;\r
14 using System.Xml.Serialization;\r
15 using System.Xml;\r
16 \r
17 namespace MonoTests.System.Xml.TestClasses\r
18 {\r
19         public enum SimpleEnumeration { FIRST, SECOND };\r
20         \r
21         public class SimpleClass\r
22         {\r
23                 public string something = null;\r
24         }\r
25 \r
26         public class StringCollection : CollectionBase\r
27         {\r
28                 public void Add (String parameter) \r
29                 {\r
30                         List.Insert (Count, parameter);\r
31                 }\r
32                         \r
33                 public String this [int index]\r
34                 {\r
35                         get\r
36                         { \r
37                                 if (index < 0 || index > Count)\r
38                                         throw new ArgumentOutOfRangeException ();\r
39                                         \r
40                                 return (String) List [index]; \r
41                         }\r
42                         set { List [index] = value; }\r
43                 }\r
44         }\r
45         \r
46         public class StringCollectionContainer\r
47         {\r
48                 StringCollection messages = new StringCollection();\r
49                 \r
50                 public StringCollection Messages\r
51                 {\r
52                         get { return messages; }\r
53                 }\r
54         }\r
55 \r
56         public class ArrayContainer\r
57         {\r
58                 public object [] items = null;\r
59         }\r
60         \r
61         public class ClassArrayContainer\r
62         {\r
63                 public SimpleClass [] items = null;\r
64         }\r
65         \r
66         [XmlRoot("simple")]\r
67         public class SimpleClassWithXmlAttributes\r
68         {\r
69                 [XmlAttribute("member")]\r
70                 public string something = null;\r
71         }\r
72         \r
73         [XmlRoot("field")]\r
74         public class Field\r
75         {\r
76                 [XmlAttribute("modifiers")]\r
77                 public MapModifiers Modifiers;\r
78         }\r
79 \r
80         [Flags]\r
81         public enum MapModifiers\r
82         {\r
83                 [XmlEnum("public")]\r
84                 Public = 0,\r
85                 [XmlEnum("protected")]\r
86                 Protected = 1,\r
87         }\r
88         \r
89         public class MyList : ArrayList\r
90         {\r
91                 object container;\r
92                 \r
93                 // NOTE: MyList has no public constructor\r
94                 public MyList (object container) : base()\r
95                 {\r
96                         this.container = container;\r
97                 }\r
98         }\r
99         \r
100         public class Container\r
101         {\r
102                 public MyList Items;\r
103                 \r
104                 public Container () {\r
105                         Items = new MyList(this);\r
106                 }\r
107         }\r
108         \r
109         public class Container2\r
110         {\r
111                 public MyList Items;\r
112                 \r
113                 public Container2 () {\r
114                 }\r
115                 \r
116                 public Container2 (bool b) {\r
117                         Items = new MyList(this);\r
118                 }\r
119         }
120 \r
121         public class MyElem: XmlElement
122         {
123                 public MyElem (XmlDocument doc): base ("","myelem","", doc)
124                 {
125                         SetAttribute ("aa","1");
126                 }
127
128                 [XmlAttribute]
129                 public int kk=1;
130         }
131 \r
132         public class MyDocument: XmlDocument
133         {
134                 public MyDocument ()
135                 {
136                 }
137
138                 [XmlAttribute]
139                 public int kk=1;
140         }
141         
142         public class CDataContainer
143         {
144                 public XmlCDataSection cdata;
145         }
146         
147         public class NodeContainer
148         {
149                 public XmlNode node;
150         }\r
151         \r
152         public class Choices\r
153         {\r
154                 [XmlElementAttribute("ChoiceZero", typeof(string), IsNullable=false)]\r
155                 [XmlElementAttribute("ChoiceOne", typeof(string), IsNullable=false)]\r
156                 [XmlElementAttribute("ChoiceTwo", typeof(string), IsNullable=false)]\r
157                 [XmlChoiceIdentifier("ItemType")]\r
158                 public string MyChoice;\r
159 \r
160                 [XmlIgnore]\r
161                 public ItemChoiceType ItemType;\r
162         }\r
163         \r
164         [XmlType(IncludeInSchema = false)]\r
165         public enum ItemChoiceType\r
166         {\r
167                 ChoiceZero,\r
168                 [XmlEnum ("ChoiceOne")]\r
169                 StrangeOne,\r
170                 ChoiceTwo,\r
171         }\r
172         \r
173         public class WrongChoices\r
174         {\r
175                 [XmlElementAttribute("ChoiceZero", typeof(string), IsNullable=false)]\r
176                 [XmlElementAttribute("StrangeOne", typeof(string), IsNullable=false)]\r
177                 [XmlElementAttribute("ChoiceTwo", typeof(string), IsNullable=false)]\r
178                 [XmlChoiceIdentifier("ItemType")]\r
179                 public string MyChoice;\r
180 \r
181                 [XmlIgnore]\r
182                 public ItemChoiceType ItemType;\r
183         }\r
184 }\r