* XmlTypeMapElementInfo.cs: no need to compare nesting level in Equals.
[mono.git] / mcs / class / System.XML / System.Xml.Serialization / XmlTypeMapElementInfo.cs
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 //
9
10 using System;
11 using System.Xml.Schema;
12 using System.Collections;
13
14 namespace System.Xml.Serialization
15 {
16         /// <summary>
17         /// Summary description for XmlTypeMapElementInfo.
18         /// </summary>
19         internal class XmlTypeMapElementInfo
20         {
21                 string _elementName;
22                 string _dataType;
23                 string _namespace = "";
24                 XmlSchemaForm _form;
25                 XmlTypeMapMember _member;
26                 string _choiceValue;
27                 bool _isNullable;
28                 int _nestingLevel;      // Only for array items
29                 XmlTypeMapping _mappedType;
30                 TypeData _type;
31                 bool _wrappedElement = true;
32
33                 public XmlTypeMapElementInfo (XmlTypeMapMember member, TypeData type)
34                 {
35                         _member = member;
36                         _type = type;
37                 }
38
39                 public TypeData TypeData
40                 {
41                         get { return _type; }
42                         set { _type = value; }
43                 }
44
45                 public string ChoiceValue
46                 {
47                         get { return _choiceValue; }
48                         set { _choiceValue = value; }
49                 }
50
51                 public string ElementName
52                 {
53                         get { return _elementName; }
54                         set { _elementName = value; }
55                 }
56
57                 public string Namespace
58                 {
59                         get { return _namespace; }
60                         set { _namespace = value; }
61                 }
62
63                 public string DataType
64                 {
65                         get { return _dataType; }
66                         set { _dataType = value; }
67                 }
68
69                 public string DataTypeNamespace
70                 {
71                         get 
72                         { 
73                                 if (_mappedType == null) return XmlSchema.Namespace;
74                                 else return _mappedType.Namespace;
75                         }
76                 }
77
78                 public XmlSchemaForm Form 
79                 {
80                         get { return _form; }
81                         set { _form = value; }
82                 }
83
84                 public XmlTypeMapping MappedType
85                 {
86                         get { return _mappedType; }
87                         set { _mappedType = value; }
88                 }
89
90                 public bool IsNullable
91                 {
92                         get { return _isNullable; }
93                         set { _isNullable = value; }
94                 }
95
96                 internal bool IsPrimitive
97                 {
98                         get { return _mappedType == null; }
99                 }
100
101                 public XmlTypeMapMember Member
102                 {
103                         get { return _member; }
104                         set { _member = value; }
105                 }
106
107                 public int NestingLevel
108                 {
109                         get { return _nestingLevel; }
110                         set { _nestingLevel = value; }
111                 }
112
113                 public bool MultiReferenceType
114                 {
115                         get 
116                         { 
117                                 if (_mappedType != null) return _mappedType.MultiReferenceType;
118                                 else return false;
119                         }
120                 }
121
122                 public bool WrappedElement
123                 {
124                         get { return _wrappedElement; }
125                         set { _wrappedElement = value; }
126                 }
127
128                 public override bool Equals (object other)
129                 {
130                         XmlTypeMapElementInfo oinfo = (XmlTypeMapElementInfo)other;
131                         if (_elementName != oinfo._elementName) return false;
132                         if (_dataType != oinfo._dataType) return false;
133                         if (_namespace != oinfo._namespace) return false;
134                         if (_form != oinfo._form) return false;
135                         if (_choiceValue != oinfo._choiceValue) return false;
136                         if (_type.Type != oinfo._type.Type) return false;
137                         if (_isNullable != oinfo._isNullable) return false;
138                         return true;
139                 }
140
141                 public override int GetHashCode ()
142                 {
143                         return base.GetHashCode ();
144                 }
145         }
146
147         class XmlTypeMapElementInfoList: ArrayList
148         {
149         }
150 }
151