mscorlib(4.0.0.0) API with additions
XmlMapping.cs
2 {
4  [global::__DynamicallyInvokable]
5  public abstract class XmlMapping
6  {
7  private TypeScope scope;
8 
9  private bool generateSerializer;
10 
11  private bool isSoap;
12 
13  private ElementAccessor accessor;
14 
15  private string key;
16 
17  private bool shallow;
18 
19  private XmlMappingAccess access;
20 
21  internal ElementAccessor Accessor => accessor;
22 
23  internal TypeScope Scope => scope;
24 
27  [global::__DynamicallyInvokable]
28  public string ElementName
29  {
30  [global::__DynamicallyInvokable]
31  get
32  {
33  return System.Xml.Serialization.Accessor.UnescapeName(Accessor.Name);
34  }
35  }
36 
39  [global::__DynamicallyInvokable]
40  public string XsdElementName
41  {
42  [global::__DynamicallyInvokable]
43  get
44  {
45  return Accessor.Name;
46  }
47  }
48 
51  [global::__DynamicallyInvokable]
52  public string Namespace
53  {
54  [global::__DynamicallyInvokable]
55  get
56  {
57  return accessor.Namespace;
58  }
59  }
60 
61  internal bool GenerateSerializer
62  {
63  get
64  {
65  return generateSerializer;
66  }
67  set
68  {
69  generateSerializer = value;
70  }
71  }
72 
73  internal bool IsReadable => (access & XmlMappingAccess.Read) != XmlMappingAccess.None;
74 
75  internal bool IsWriteable => (access & XmlMappingAccess.Write) != XmlMappingAccess.None;
76 
77  internal bool IsSoap
78  {
79  get
80  {
81  return isSoap;
82  }
83  set
84  {
85  isSoap = value;
86  }
87  }
88 
89  internal string Key => key;
90 
91  internal XmlMapping(TypeScope scope, ElementAccessor accessor)
92  : this(scope, accessor, XmlMappingAccess.Read | XmlMappingAccess.Write)
93  {
94  }
95 
96  internal XmlMapping(TypeScope scope, ElementAccessor accessor, XmlMappingAccess access)
97  {
98  this.scope = scope;
99  this.accessor = accessor;
100  this.access = access;
101  shallow = (scope == null);
102  }
103 
106  [global::__DynamicallyInvokable]
107  public void SetKey(string key)
108  {
109  SetKeyInternal(key);
110  }
111 
112  internal void SetKeyInternal(string key)
113  {
114  this.key = key;
115  }
116 
117  internal static string GenerateKey(Type type, XmlRootAttribute root, string ns)
118  {
119  if (root == null)
120  {
121  root = (XmlRootAttribute)XmlAttributes.GetAttr(type, typeof(XmlRootAttribute));
122  }
123  return type.FullName + ":" + ((root == null) ? string.Empty : root.Key) + ":" + ((ns == null) ? string.Empty : ns);
124  }
125 
126  internal void CheckShallow()
127  {
128  if (shallow)
129  {
130  throw new InvalidOperationException(Res.GetString("XmlMelformMapping"));
131  }
132  }
133 
134  internal static bool IsShallow(XmlMapping[] mappings)
135  {
136  for (int i = 0; i < mappings.Length; i++)
137  {
138  if (mappings[i] == null || mappings[i].shallow)
139  {
140  return true;
141  }
142  }
143  return false;
144  }
145  }
146 }
string Namespace
Gets the namespace of the mapped element.
Definition: XmlMapping.cs:53
abstract string FullName
Gets the fully qualified name of the type, including its namespace but not its assembly.
Definition: Type.cs:153
Definition: __Canon.cs:3
XmlMappingAccess
Specifies whether a mapping is read, write, or both.
Supports mappings between .NET Framework types and XML Schema data types.
Definition: XmlMapping.cs:5
Represents type declarations: class types, interface types, array types, value types,...
Definition: Type.cs:18
string ElementName
Get the name of the mapped element.
Definition: XmlMapping.cs:29
void SetKey(string key)
Sets the key used to look up the mapping.
Definition: XmlMapping.cs:107
string XsdElementName
Gets the name of the XSD element of the mapping.
Definition: XmlMapping.cs:41