**** Merged from MCS ****
[mono-project.git] / mcs / class / System.XML / System.Xml.Serialization / XmlTypeMapElementInfo.cs
blob08b0d968413315d7f0e2d88aafeb189a7114e799
1 //
2 // XmlTypeMapElementInfo.cs:
3 //
4 // Author:
5 // Lluis Sanchez Gual (lluis@ximian.com)
6 //
7 // (C) 2002, 2003 Ximian, Inc. http://www.ximian.com
8 //
11 // Permission is hereby granted, free of charge, to any person obtaining
12 // a copy of this software and associated documentation files (the
13 // "Software"), to deal in the Software without restriction, including
14 // without limitation the rights to use, copy, modify, merge, publish,
15 // distribute, sublicense, and/or sell copies of the Software, and to
16 // permit persons to whom the Software is furnished to do so, subject to
17 // the following conditions:
18 //
19 // The above copyright notice and this permission notice shall be
20 // included in all copies or substantial portions of the Software.
21 //
22 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
26 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
27 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31 using System;
32 using System.Xml.Schema;
33 using System.Collections;
35 namespace System.Xml.Serialization
37 /// <summary>
38 /// Summary description for XmlTypeMapElementInfo.
39 /// </summary>
40 internal class XmlTypeMapElementInfo
42 string _elementName;
43 string _namespace = "";
44 XmlSchemaForm _form;
45 XmlTypeMapMember _member;
46 string _choiceValue;
47 bool _isNullable;
48 int _nestingLevel; // Only for array items
49 XmlTypeMapping _mappedType;
50 TypeData _type;
51 bool _wrappedElement = true;
53 public XmlTypeMapElementInfo (XmlTypeMapMember member, TypeData type)
55 _member = member;
56 _type = type;
59 public TypeData TypeData
61 get { return _type; }
62 set { _type = value; }
65 public string ChoiceValue
67 get { return _choiceValue; }
68 set { _choiceValue = value; }
71 public string ElementName
73 get { return _elementName; }
74 set { _elementName = value; }
77 public string Namespace
79 get { return _namespace; }
80 set { _namespace = value; }
83 public string DataTypeNamespace
85 get
87 if (_mappedType == null) return XmlSchema.Namespace;
88 else return _mappedType.XmlTypeNamespace;
92 public XmlSchemaForm Form
94 get { return _form; }
95 set { _form = value; }
98 public XmlTypeMapping MappedType
100 get { return _mappedType; }
101 set { _mappedType = value; }
104 public bool IsNullable
106 get { return _isNullable; }
107 set { _isNullable = value; }
110 internal bool IsPrimitive
112 get { return _mappedType == null; }
115 public XmlTypeMapMember Member
117 get { return _member; }
118 set { _member = value; }
121 public int NestingLevel
123 get { return _nestingLevel; }
124 set { _nestingLevel = value; }
127 public bool MultiReferenceType
129 get
131 if (_mappedType != null) return _mappedType.MultiReferenceType;
132 else return false;
136 public bool WrappedElement
138 get { return _wrappedElement; }
139 set { _wrappedElement = value; }
142 public bool IsTextElement
144 get { return ElementName == "<text>"; }
145 set { ElementName = "<text>"; Namespace = string.Empty; }
148 public bool IsUnnamedAnyElement
150 get { return ElementName == string.Empty; }
151 set { ElementName = string.Empty; Namespace = string.Empty; }
154 public override bool Equals (object other)
156 XmlTypeMapElementInfo oinfo = (XmlTypeMapElementInfo)other;
157 if (_elementName != oinfo._elementName) return false;
158 if (_type.XmlType != oinfo._type.XmlType) return false;
159 if (_namespace != oinfo._namespace) return false;
160 if (_form != oinfo._form) return false;
161 if (_choiceValue != oinfo._choiceValue) return false;
162 if (_type != oinfo._type) return false;
163 if (_isNullable != oinfo._isNullable) return false;
164 return true;
167 public override int GetHashCode ()
169 return base.GetHashCode ();
173 class XmlTypeMapElementInfoList: ArrayList