mscorlib(4.0.0.0) API with additions
Accessor.cs
1 using System.Xml.Schema;
2 
4 {
5  internal abstract class Accessor
6  {
7  private string name;
8 
9  private object defaultValue;
10 
11  private string ns;
12 
13  private TypeMapping mapping;
14 
15  private bool any;
16 
17  private string anyNs;
18 
19  private bool topLevelInSchema;
20 
21  private bool isFixed;
22 
23  private bool isOptional;
24 
25  private XmlSchemaForm form;
26 
27  internal TypeMapping Mapping
28  {
29  get
30  {
31  return mapping;
32  }
33  set
34  {
35  mapping = value;
36  }
37  }
38 
39  internal object Default
40  {
41  get
42  {
43  return defaultValue;
44  }
45  set
46  {
47  defaultValue = value;
48  }
49  }
50 
51  internal bool HasDefault
52  {
53  get
54  {
55  if (defaultValue != null)
56  {
57  return defaultValue != DBNull.Value;
58  }
59  return false;
60  }
61  }
62 
63  internal virtual string Name
64  {
65  get
66  {
67  if (name != null)
68  {
69  return name;
70  }
71  return string.Empty;
72  }
73  set
74  {
75  name = value;
76  }
77  }
78 
79  internal bool Any
80  {
81  get
82  {
83  return any;
84  }
85  set
86  {
87  any = value;
88  }
89  }
90 
91  internal string AnyNamespaces
92  {
93  get
94  {
95  return anyNs;
96  }
97  set
98  {
99  anyNs = value;
100  }
101  }
102 
103  internal string Namespace
104  {
105  get
106  {
107  return ns;
108  }
109  set
110  {
111  ns = value;
112  }
113  }
114 
115  internal XmlSchemaForm Form
116  {
117  get
118  {
119  return form;
120  }
121  set
122  {
123  form = value;
124  }
125  }
126 
127  internal bool IsFixed
128  {
129  get
130  {
131  return isFixed;
132  }
133  set
134  {
135  isFixed = value;
136  }
137  }
138 
139  internal bool IsOptional
140  {
141  get
142  {
143  return isOptional;
144  }
145  set
146  {
147  isOptional = value;
148  }
149  }
150 
151  internal bool IsTopLevelInSchema
152  {
153  get
154  {
155  return topLevelInSchema;
156  }
157  set
158  {
159  topLevelInSchema = value;
160  }
161  }
162 
163  internal Accessor()
164  {
165  }
166 
167  internal static string EscapeName(string name)
168  {
169  if (name == null || name.Length == 0)
170  {
171  return name;
172  }
173  return XmlConvert.EncodeLocalName(name);
174  }
175 
176  internal static string EscapeQName(string name)
177  {
178  if (name == null || name.Length == 0)
179  {
180  return name;
181  }
182  int num = name.LastIndexOf(':');
183  if (num < 0)
184  {
185  return XmlConvert.EncodeLocalName(name);
186  }
187  if (num == 0 || num == name.Length - 1)
188  {
189  throw new ArgumentException(Res.GetString("Xml_InvalidNameChars", name), "name");
190  }
191  return new XmlQualifiedName(XmlConvert.EncodeLocalName(name.Substring(num + 1)), XmlConvert.EncodeLocalName(name.Substring(0, num))).ToString();
192  }
193 
194  internal static string UnescapeName(string name)
195  {
196  return XmlConvert.DecodeName(name);
197  }
198 
199  internal string ToString(string defaultNs)
200  {
201  if (Any)
202  {
203  return ((Namespace == null) ? "##any" : Namespace) + ":" + Name;
204  }
205  if (!(Namespace == defaultNs))
206  {
207  return Namespace + ":" + Name;
208  }
209  return Name;
210  }
211  }
212 }
XmlSchemaForm
Indicates if attributes or elements need to be qualified with a namespace prefix.
Definition: XmlSchemaForm.cs:7
Definition: __Canon.cs:3
static string EncodeLocalName(string name)
Converts the name to a valid XML local name.
Definition: XmlConvert.cs:72
static string DecodeName(string name)
Decodes a name. This method does the reverse of the M:System.Xml.XmlConvert.EncodeName(System....
Definition: XmlConvert.cs:81
static readonly DBNull Value
Represents the sole instance of the T:System.DBNull class.
Definition: DBNull.cs:13
Represents an XML qualified name.
The exception that is thrown when one of the arguments provided to a method is not valid.
This value supports the .NET Framework infrastructure and is not intended to be used directly from yo...
override string ToString()
Returns the string value of the T:System.Xml.XmlQualifiedName.
The default setting for this enumeration, which is currently F:System.GCCollectionMode....
Encodes and decodes XML names, and provides methods for converting between common language runtime ty...
Definition: XmlConvert.cs:11
Represents a nonexistent value. This class cannot be inherited.
Definition: DBNull.cs:10