Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ AddAttribute()

XmlSchemaAttribute System.Xml.Schema.XmlSchemaInference.AddAttribute ( string localName,
string prefix,
string childURI,
string attrValue,
bool bCreatingNewType,
XmlSchema parentSchema,
XmlSchemaObjectCollection addLocation,
XmlSchemaObjectTable compiledAttributes )
inlineprivate

Definition at line 179 of file XmlSchemaInference.cs.

180 {
181 if (childURI == "http://www.w3.org/2001/XMLSchema")
182 {
183 throw new XmlSchemaInferenceException(System.SR.SchInf_schema, 0, 0);
184 }
185 XmlSchemaAttribute xmlSchemaAttribute = null;
186 int iTypeFlags = -1;
187 XmlSchemaAttribute xmlSchemaAttribute2 = null;
188 XmlSchema xmlSchema = null;
189 bool flag = true;
190 ICollection attributes;
192 if (compiledAttributes.Count > 0)
193 {
194 attributes = compiledAttributes.Values;
196 }
197 else
198 {
199 attributes = addLocation;
200 collection = null;
201 }
202 if (childURI == "http://www.w3.org/XML/1998/namespace")
203 {
204 XmlSchemaAttribute xmlSchemaAttribute3 = null;
205 xmlSchemaAttribute3 = FindAttributeRef(attributes, localName, childURI);
206 if (xmlSchemaAttribute3 == null && collection != null)
207 {
209 }
210 if (xmlSchemaAttribute3 == null)
211 {
212 xmlSchemaAttribute3 = new XmlSchemaAttribute();
213 xmlSchemaAttribute3.RefName = new XmlQualifiedName(localName, childURI);
214 if (bCreatingNewType && Occurrence == InferenceOption.Restricted)
215 {
216 xmlSchemaAttribute3.Use = XmlSchemaUse.Required;
217 }
218 else
219 {
220 xmlSchemaAttribute3.Use = XmlSchemaUse.Optional;
221 }
223 }
225 }
226 else
227 {
228 if (childURI.Length == 0)
229 {
231 flag = false;
232 }
233 else if (childURI != null && !_schemaSet.Contains(childURI))
234 {
235 xmlSchema = new XmlSchema();
236 xmlSchema.AttributeFormDefault = XmlSchemaForm.Unqualified;
237 xmlSchema.ElementFormDefault = XmlSchemaForm.Qualified;
238 if (childURI.Length != 0)
239 {
241 }
243 if (prefix.Length != 0 && !string.Equals(prefix, "xml", StringComparison.OrdinalIgnoreCase))
244 {
246 }
247 }
248 else if (_schemaSet.Schemas(childURI) is ArrayList { Count: >0 } arrayList)
249 {
250 xmlSchema = arrayList[0] as XmlSchema;
251 }
252 if (childURI.Length != 0)
253 {
254 XmlSchemaAttribute xmlSchemaAttribute4 = null;
255 xmlSchemaAttribute4 = FindAttributeRef(attributes, localName, childURI);
256 if (xmlSchemaAttribute4 == null && collection != null)
257 {
259 }
260 if (xmlSchemaAttribute4 == null)
261 {
262 xmlSchemaAttribute4 = new XmlSchemaAttribute();
263 xmlSchemaAttribute4.RefName = new XmlQualifiedName(localName, childURI);
264 if (bCreatingNewType && Occurrence == InferenceOption.Restricted)
265 {
266 xmlSchemaAttribute4.Use = XmlSchemaUse.Required;
267 }
268 else
269 {
270 xmlSchemaAttribute4.Use = XmlSchemaUse.Optional;
271 }
273 }
275 xmlSchemaAttribute = FindAttribute(xmlSchema.Items, localName);
276 if (xmlSchemaAttribute == null)
277 {
278 xmlSchemaAttribute = new XmlSchemaAttribute();
279 xmlSchemaAttribute.Name = localName;
282 xmlSchema.Items.Add(xmlSchemaAttribute);
283 }
284 else
285 {
286 if (xmlSchemaAttribute.Parent == null)
287 {
288 iTypeFlags = xmlSchemaAttribute.LineNumber;
289 }
290 else
291 {
294 }
297 }
298 }
299 else
300 {
301 xmlSchemaAttribute = FindAttribute(attributes, localName);
302 if (xmlSchemaAttribute == null && collection != null)
303 {
305 }
306 if (xmlSchemaAttribute == null)
307 {
308 xmlSchemaAttribute = new XmlSchemaAttribute();
309 xmlSchemaAttribute.Name = localName;
312 if (bCreatingNewType && Occurrence == InferenceOption.Restricted)
313 {
314 xmlSchemaAttribute.Use = XmlSchemaUse.Required;
315 }
316 else
317 {
318 xmlSchemaAttribute.Use = XmlSchemaUse.Optional;
319 }
321 if (xmlSchema.AttributeFormDefault != XmlSchemaForm.Unqualified)
322 {
323 xmlSchemaAttribute.Form = XmlSchemaForm.Unqualified;
324 }
325 }
326 else
327 {
328 if (xmlSchemaAttribute.Parent == null)
329 {
330 iTypeFlags = xmlSchemaAttribute.LineNumber;
331 }
332 else
333 {
336 }
339 }
341 }
342 }
343 string @namespace = null;
344 if (flag && childURI != parentSchema.TargetNamespace)
345 {
346 for (int i = 0; i < parentSchema.Includes.Count; i++)
347 {
348 if (parentSchema.Includes[i] is XmlSchemaImport xmlSchemaImport && xmlSchemaImport.Namespace == childURI)
349 {
350 flag = false;
351 }
352 }
353 if (flag)
354 {
355 XmlSchemaImport xmlSchemaImport2 = new XmlSchemaImport();
356 xmlSchemaImport2.Schema = xmlSchema;
357 if (childURI.Length != 0)
358 {
359 @namespace = childURI;
360 }
361 xmlSchemaImport2.Namespace = @namespace;
362 parentSchema.Includes.Add(xmlSchemaImport2);
363 }
364 }
365 return xmlSchemaAttribute2;
366 }
static string SchInf_schema
Definition SR.cs:1208
Definition SR.cs:7
XmlSchemaAttribute FindAttributeRef(ICollection attributes, string attributeName, string nsURI)
XmlSchemaAttribute FindAttribute(ICollection attributes, string attrName)
XmlQualifiedName RefineSimpleType(string s, ref int iTypeFlags)
readonly XmlNamespaceManager _namespaceManager
static int GetSchemaType(XmlQualifiedName qname)
bool Contains(string? targetNamespace)
XmlSchema? Add(string? targetNamespace, string schemaUri)
virtual void AddNamespace(string prefix, string uri)

References System.Xml.Schema.XmlSchemaInference._namespaceManager, System.Xml.Schema.XmlSchemaInference._schemaSet, System.Xml.Schema.XmlSchemaSet.Add(), System.Xml.Schema.XmlSchemaObjectCollection.Add(), System.Xml.XmlNamespaceManager.AddNamespace(), System.collection, System.Xml.Schema.XmlSchemaSet.Contains(), System.Collections.CollectionBase.Count, System.Xml.Dictionary, System.Xml.Schema.XmlSchemaInference.FindAttribute(), System.Xml.Schema.XmlSchemaInference.FindAttributeRef(), System.Xml.Schema.XmlSchemaInference.GetSchemaType(), System.Xml.Schema.XmlSchema.Includes, System.Xml.Schema.XmlSchemaImport.Namespace, System.Xml.Schema.XmlSchemaInference.Occurrence, System.prefix, System.Xml.Schema.XmlSchemaInference.RefineSimpleType(), System.Xml.Schema.XmlSchemaSet.Schemas(), System.SR.SchInf_schema, and System.Xml.Schema.XmlSchema.TargetNamespace.