本文整理汇总了C#中System.Xml.Schema.XmlSchemaObjectCollection.Insert方法的典型用法代码示例。如果您正苦于以下问题:C# XmlSchemaObjectCollection.Insert方法的具体用法?C# XmlSchemaObjectCollection.Insert怎么用?C# XmlSchemaObjectCollection.Insert使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.Schema.XmlSchemaObjectCollection
的用法示例。
在下文中一共展示了XmlSchemaObjectCollection.Insert方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddElement
//.........这里部分代码省略.........
if (col != null && col.Count > 0 )
{
xs = col[0] as XmlSchema;
}
xse = new XmlSchemaElement();
xse.Name = localName;
xs.Items.Add(xse);
}
else
bCreatingNewType = false;
}
else
{
xs = CreateXmlSchema(childURI);
if (prefix.Length!=0)
NamespaceManager.AddNamespace(prefix, childURI);
xse=new XmlSchemaElement();
xse.Name = localName;
xs.Items.Add(xse); //add global element declaration only when creating new schema
}
if (parentSchema == null)
{
parentSchema = xs;
this.rootSchema = parentSchema;
}
if (childURI != parentSchema.TargetNamespace )
{
bool add = true;
for (int i = 0; i < parentSchema.Includes.Count; ++i)
{
XmlSchemaImport import = parentSchema.Includes[i] as XmlSchemaImport;
if (import == null)
{
continue;
}
//Debug.WriteLine(import.Schema.TargetNamespace);
if (import.Namespace == childURI)
{
add = false;
}
}
if (add)
{
XmlSchemaImport import = new XmlSchemaImport();
import.Schema = xs;
import.Namespace = childURI;
parentSchema.Includes.Add(import);
}
}
returnedElement = xse;
if (addLocation != null)
{
if (childURI == parentSchema.TargetNamespace )
{
if (this.Occurrence == InferenceOption.Relaxed /*&& parentSchema.Items != addLocation*/)
{
xse.MinOccurs = 0;
}
if (positionWithinCollection == -1)
{
positionWithinCollection = addLocation.Add(xse);
}
else
{
addLocation.Insert(positionWithinCollection, xse);
}
}
else
{
XmlSchemaElement elementReference = new XmlSchemaElement();
elementReference.RefName = new XmlQualifiedName(localName, childURI);
if (this.Occurrence == InferenceOption.Relaxed)
{
elementReference.MinOccurs = 0;
}
if (positionWithinCollection == -1)
{
positionWithinCollection = addLocation.Add(elementReference);
}
else
{
addLocation.Insert(positionWithinCollection, elementReference);
}
returnedElement = elementReference;
/* if (childURI == XmlSchema.Namespace)
{
schemaList.Add(new ReplaceList(addLocation, positionWithinCollection));
}*/
}
}
InferElement(xse, bCreatingNewType, xs);
return returnedElement;
}
示例2: AddElement
private XmlSchemaElement AddElement(string localName, string prefix, string childURI, XmlSchema parentSchema, XmlSchemaObjectCollection addLocation, int positionWithinCollection)
{
if (childURI == "http://www.w3.org/2001/XMLSchema")
{
throw new XmlSchemaInferenceException("SchInf_schema", 0, 0);
}
XmlSchemaElement item = null;
XmlSchemaElement element2 = item;
XmlSchema schema = null;
bool bCreatingNewType = true;
if (childURI == string.Empty)
{
childURI = null;
}
if ((parentSchema != null) && (childURI == parentSchema.TargetNamespace))
{
item = new XmlSchemaElement {
Name = localName
};
schema = parentSchema;
if ((schema.ElementFormDefault != XmlSchemaForm.Qualified) && (addLocation != null))
{
item.Form = XmlSchemaForm.Qualified;
}
}
else if (this.schemaSet.Contains(childURI))
{
item = this.FindGlobalElement(childURI, localName, out schema);
if (item == null)
{
ArrayList list = this.schemaSet.Schemas(childURI) as ArrayList;
if ((list != null) && (list.Count > 0))
{
schema = list[0] as XmlSchema;
}
item = new XmlSchemaElement {
Name = localName
};
schema.Items.Add(item);
}
else
{
bCreatingNewType = false;
}
}
else
{
schema = this.CreateXmlSchema(childURI);
if (prefix.Length != 0)
{
this.NamespaceManager.AddNamespace(prefix, childURI);
}
item = new XmlSchemaElement {
Name = localName
};
schema.Items.Add(item);
}
if (parentSchema == null)
{
parentSchema = schema;
this.rootSchema = parentSchema;
}
if (childURI != parentSchema.TargetNamespace)
{
bool flag2 = true;
for (int i = 0; i < parentSchema.Includes.Count; i++)
{
XmlSchemaImport import = parentSchema.Includes[i] as XmlSchemaImport;
if ((import != null) && (import.Namespace == childURI))
{
flag2 = false;
}
}
if (flag2)
{
XmlSchemaImport import2 = new XmlSchemaImport {
Schema = schema,
Namespace = childURI
};
parentSchema.Includes.Add(import2);
}
}
element2 = item;
if (addLocation != null)
{
if (childURI == parentSchema.TargetNamespace)
{
if (this.Occurrence == InferenceOption.Relaxed)
{
item.MinOccurs = 0M;
}
if (positionWithinCollection == -1)
{
positionWithinCollection = addLocation.Add(item);
}
else
{
addLocation.Insert(positionWithinCollection, item);
}
}
//.........这里部分代码省略.........