**** Merged from MCS ****
[mono-project.git] / mcs / class / System.XML / System.Xml.Serialization / XmlMemberMapping.cs
blob205715e7967777facc41bc02819878ff4cd9035b
1 //
2 // System.Xml.Serialization.XmlMemberMapping
3 //
4 // Author:
5 // Tim Coleman (tim@timcoleman.com)
6 // Lluis Sanchez Gual (lluis@ximian.com)
7 //
8 // Copyright (C) Tim Coleman, 2002
9 //
12 // Permission is hereby granted, free of charge, to any person obtaining
13 // a copy of this software and associated documentation files (the
14 // "Software"), to deal in the Software without restriction, including
15 // without limitation the rights to use, copy, modify, merge, publish,
16 // distribute, sublicense, and/or sell copies of the Software, and to
17 // permit persons to whom the Software is furnished to do so, subject to
18 // the following conditions:
19 //
20 // The above copyright notice and this permission notice shall be
21 // included in all copies or substantial portions of the Software.
22 //
23 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
27 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
28 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
29 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
32 using System.Xml.Schema;
34 namespace System.Xml.Serialization
36 public class XmlMemberMapping {
38 XmlTypeMapMember _mapMember;
39 string _elementName;
40 string _memberName;
41 string _namespace;
42 string _typeNamespace;
43 XmlSchemaForm _form;
45 internal XmlMemberMapping (string memberName, string defaultNamespace, XmlTypeMapMember mapMem, bool encodedFormat)
47 _mapMember = mapMem;
48 _memberName = memberName;
50 if (mapMem is XmlTypeMapMemberAnyElement)
52 XmlTypeMapMemberAnyElement anyelem = (XmlTypeMapMemberAnyElement) mapMem;
53 XmlTypeMapElementInfo info = (XmlTypeMapElementInfo) anyelem.ElementInfo[anyelem.ElementInfo.Count-1];
54 _elementName = info.ElementName;
55 _namespace = info.Namespace;
56 if (info.MappedType != null) _typeNamespace = info.MappedType.Namespace;
57 else _typeNamespace = "";
59 else if (mapMem is XmlTypeMapMemberElement)
61 XmlTypeMapElementInfo info = (XmlTypeMapElementInfo) ((XmlTypeMapMemberElement)mapMem).ElementInfo[0];
62 _elementName = info.ElementName;
63 if (encodedFormat)
65 _namespace = defaultNamespace;
66 if (info.MappedType != null) _typeNamespace = "";
67 else _typeNamespace = info.DataTypeNamespace;
69 else
71 _namespace = info.Namespace;
72 if (info.MappedType != null) _typeNamespace = info.MappedType.Namespace;
73 else _typeNamespace = "";
74 _form = info.Form;
77 else
79 _elementName = _memberName;
80 _namespace = "";
83 if (_form == XmlSchemaForm.None)
84 _form = XmlSchemaForm.Qualified;
87 #region Properties
89 public bool Any {
90 get { return _mapMember is XmlTypeMapMemberAnyElement; }
93 public string ElementName {
94 get { return _elementName; }
97 public string MemberName {
98 get { return _memberName; }
101 public string Namespace {
102 get { return _namespace; }
105 public string TypeFullName {
106 get { return _mapMember.TypeData.FullTypeName; }
109 public string TypeName {
110 get { return _mapMember.TypeData.XmlType; }
113 public string TypeNamespace {
114 get { return _typeNamespace; }
117 internal XmlTypeMapMember TypeMapMember {
118 get { return _mapMember; }
121 internal XmlSchemaForm Form {
122 get { return _form; }
125 #if NET_2_0
126 [MonoTODO]
127 public bool IsNullable
129 get { throw new NotImplementedException (); }
132 [MonoTODO]
133 public string GetTypeName (System.CodeDom.Compiler.ICodeGenerator codeGenerator)
135 throw new NotImplementedException ();
137 #endif
139 #if NET_1_1
140 public bool CheckSpecified
142 get { return _mapMember.IsOptionalValueType; }
144 #endif
146 #endregion // Properties