本文整理汇总了C#中System.Xml.Schema.XmlSchemaElement类的典型用法代码示例。如果您正苦于以下问题:C# XmlSchemaElement类的具体用法?C# XmlSchemaElement怎么用?C# XmlSchemaElement使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
XmlSchemaElement类属于System.Xml.Schema命名空间,在下文中一共展示了XmlSchemaElement类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddElementToSchema
void AddElementToSchema(XmlSchemaElement element, string elementNs, XmlSchemaSet schemaSet)
{
OperationDescription parentOperation = this.operation;
if (parentOperation.OperationMethod != null)
{
XmlQualifiedName qname = new XmlQualifiedName(element.Name, elementNs);
OperationElement existingElement;
if (ExportedMessages.ElementTypes.TryGetValue(qname, out existingElement))
{
if (existingElement.Operation.OperationMethod == parentOperation.OperationMethod)
return;
if (!SchemaHelper.IsMatch(element, existingElement.Element))
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.CannotHaveTwoOperationsWithTheSameElement5, parentOperation.OperationMethod.DeclaringType, parentOperation.OperationMethod.Name, qname, existingElement.Operation.OperationMethod.DeclaringType, existingElement.Operation.Name)));
}
return;
}
else
{
ExportedMessages.ElementTypes.Add(qname, new OperationElement(element, parentOperation));
}
}
SchemaHelper.AddElementToSchema(element, SchemaHelper.GetSchema(elementNs, schemaSet), schemaSet);
}
示例2: ReplaceThisWith
public static void ReplaceThisWith(this XmlSchemaElement that, XmlSchemaElement with)
{
var gr = that.Parent as XmlSchemaGroupBase;
int idx = gr.Items.IndexOf(that);
gr.Items.Insert(idx, with);
gr.Items.Remove(that);
}
示例3: Bug360541
public void Bug360541 ()
{
XmlSchemaComplexType stype = GetStype ();
XmlSchemaElement selem1 = new XmlSchemaElement ();
selem1.Name = "schema";
selem1.SchemaType = stype;
XmlSchema schema = new XmlSchema ();
schema.Items.Add (selem1);
XmlSchemas xs = new XmlSchemas ();
xs.Add (schema);
xs.Find (XmlQualifiedName.Empty, typeof (XmlSchemaElement));
selem1 = new XmlSchemaElement ();
selem1.Name = "schema1";
selem1.SchemaType = stype;
schema = new XmlSchema ();
schema.Items.Add (selem1);
xs = new XmlSchemas ();
xs.Add (schema);
xs.Find (XmlQualifiedName.Empty, typeof (XmlSchemaElement));
}
示例4: TestAdd
public void TestAdd ()
{
XmlSchemaCollection col = new XmlSchemaCollection ();
XmlSchema schema = new XmlSchema ();
XmlSchemaElement elem = new XmlSchemaElement ();
elem.Name = "foo";
schema.Items.Add (elem);
schema.TargetNamespace = "urn:foo";
col.Add (schema);
col.Add (schema); // No problem !?
XmlSchema schema2 = new XmlSchema ();
schema2.Items.Add (elem);
schema2.TargetNamespace = "urn:foo";
col.Add (schema2); // No problem !!
schema.Compile (null);
col.Add (schema);
col.Add (schema); // Still no problem !!!
schema2.Compile (null);
col.Add (schema2);
schema = GetSchema ("Test/XmlFiles/xsd/3.xsd");
schema.Compile (null);
col.Add (schema);
schema2 = GetSchema ("Test/XmlFiles/xsd/3.xsd");
schema2.Compile (null);
col.Add (schema2);
}
示例5: DescriptrosCollector
public DescriptrosCollector(XmlSchemaElement element)
{
if (element == null) throw new ArgumentNullException("element");
this.element = element;
Collect();
}
示例6: SchemaObjectInfo
internal SchemaObjectInfo(XmlSchemaType type, XmlSchemaElement element, XmlSchema schema, List<XmlSchemaType> knownTypes)
{
this.type = type;
this.element = element;
this.schema = schema;
this.knownTypes = knownTypes;
}
示例7: CheckDuplicateElement
internal void CheckDuplicateElement(XmlSchemaElement element, string elementNs)
{
if ((element != null) && ((element.Parent != null) && (element.Parent is XmlSchema)))
{
XmlSchemaObjectTable elements = null;
if ((this.Schema != null) && (this.Schema.TargetNamespace == elementNs))
{
XmlSchemas.Preprocess(this.Schema);
elements = this.Schema.Elements;
}
else if (this.Schemas != null)
{
elements = this.Schemas.GlobalElements;
}
else
{
return;
}
foreach (XmlSchemaElement element2 in elements.Values)
{
if ((element2.Name == element.Name) && (element2.QualifiedName.Namespace == elementNs))
{
if (!this.Match(element2, element))
{
throw new InvalidOperationException(Res.GetString("XmlSerializableRootDupName", new object[] { this.getSchemaMethod.DeclaringType.FullName, element2.Name, elementNs }));
}
break;
}
}
}
}
示例8: AddElementForm
internal static void AddElementForm(XmlSchemaElement element, System.Xml.Schema.XmlSchema schema)
{
if (schema.ElementFormDefault != XmlSchemaForm.Qualified)
{
element.Form = XmlSchemaForm.Qualified;
}
}
示例9: GetXmlSchema
/// <summary>
/// Gets the XML schema.
/// </summary>
/// <param name="type">The type.</param>
/// <param name="schemaSet">The schema set.</param>
/// <param name="generateFlatSchema">A value indicating whether the schema should be generated as flat schema.</param>
/// <returns>The qualified name of the type.</returns>
/// <exception cref="ArgumentNullException">The <paramref name="schemaSet"/> is <c>null</c>.</exception>
public static XmlQualifiedName GetXmlSchema(Type type, XmlSchemaSet schemaSet, bool generateFlatSchema)
{
Argument.IsNotNull("schemaSet", schemaSet);
var dependencyResolver = IoCConfiguration.DefaultDependencyResolver;
var serializationManager = dependencyResolver.Resolve<ISerializationManager>();
string typeNs = GetTypeNamespaceForSchema(type);
var schema = GetOrCreateSchema(typeNs, schemaSet, serializationManager);
// Check if it already exists
string typeName = GetTypeNameForSchema(type);
var existingType = (from x in schema.Items.Cast<object>()
where x is XmlSchemaComplexType && ((XmlSchemaComplexType)x).Name == typeName
select (XmlSchemaComplexType)x).FirstOrDefault();
if (existingType != null)
{
return new XmlQualifiedName(existingType.Name, typeNs);
}
var typeSchema = CreateSchemaComplexType(type, schema, schemaSet, serializationManager, generateFlatSchema);
var root = new XmlSchemaElement();
root.Name = string.Format("{0}", typeSchema.Name);
root.SchemaTypeName = new XmlQualifiedName(typeSchema.Name, typeNs);
root.IsNillable = true;
schema.Items.Add(root);
return new XmlQualifiedName(typeSchema.Name, typeNs);
}
示例10: GenerateTypedDataSet
internal string GenerateTypedDataSet(XmlSchemaElement element, XmlSchemas schemas, CodeCompileUnit compileUnit, CodeNamespace mainNamespace, CodeDomProvider codeProvider)
{
if (element == null)
{
return null;
}
if (this.importedTypes[element.SchemaType] != null)
{
return (string) this.importedTypes[element.SchemaType];
}
IList list = schemas.GetSchemas(element.QualifiedName.Namespace);
if (list.Count != 1)
{
return null;
}
XmlSchema schema = list[0] as XmlSchema;
if (schema == null)
{
return null;
}
MemoryStream stream = new MemoryStream();
schema.Write(stream);
stream.Position = 0L;
DesignDataSource designDS = new DesignDataSource();
designDS.ReadXmlSchema(stream, null);
stream.Close();
string str = TypedDataSetGenerator.GenerateInternal(designDS, compileUnit, mainNamespace, codeProvider, this.dataSetGenerateOptions, null);
this.importedTypes.Add(element.SchemaType, str);
return str;
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:30,代码来源:TypedDataSetSchemaImporterExtension.cs
示例11: GenerateTypedDataSet
internal string GenerateTypedDataSet(XmlSchemaElement element, XmlSchemas schemas, CodeNamespace codeNamespace, StringCollection references, CodeDomProvider codeProvider)
{
if (element == null)
{
return null;
}
if (this.importedTypes[element.SchemaType] != null)
{
return (string) this.importedTypes[element.SchemaType];
}
IList list = schemas.GetSchemas(element.QualifiedName.Namespace);
if (list.Count != 1)
{
return null;
}
XmlSchema schema = list[0] as XmlSchema;
if (schema == null)
{
return null;
}
DataSet dataSet = new DataSet();
using (MemoryStream stream = new MemoryStream())
{
schema.Write(stream);
stream.Position = 0L;
dataSet.ReadXmlSchema(stream);
}
string name = new TypedDataSetGenerator().GenerateCode(dataSet, codeNamespace, codeProvider.CreateGenerator()).Name;
this.importedTypes.Add(element.SchemaType, name);
references.Add("System.Data.dll");
return name;
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:32,代码来源:DataSetSchemaImporterExtension.cs
示例12: Visit
protected override void Visit(XmlSchemaElement element)
{
var sameNamespace = element.QualifiedName.Namespace == _targetNamespace ||
string.IsNullOrEmpty(element.QualifiedName.Namespace) && string.IsNullOrEmpty(_targetNamespace);
if (!sameNamespace)
return;
var isGlobal = (element.Parent is XmlSchema);
if (isGlobal)
{
_elements.Add(element);
base.Visit(element);
}
else if (element.RefName.IsEmpty)
{
base.Visit(element);
}
else
{
var elementParent = FindOuterMostElement(element);
var referencedElement = (XmlSchemaElement)_schemaSet.GlobalElements[element.RefName];
if (referencedElement != elementParent)
_referencedElements.Add(referencedElement);
}
}
示例13: TestSimpleValidation
public void TestSimpleValidation ()
{
string xml = "<root/>";
xvr = PrepareXmlReader (xml);
Assert.AreEqual (ValidationType.Auto, xvr.ValidationType);
XmlSchema schema = new XmlSchema ();
XmlSchemaElement elem = new XmlSchemaElement ();
elem.Name = "root";
schema.Items.Add (elem);
xvr.Schemas.Add (schema);
xvr.Read (); // root
Assert.AreEqual (ValidationType.Auto, xvr.ValidationType);
xvr.Read (); // EOF
xml = "<hoge/>";
xvr = PrepareXmlReader (xml);
xvr.Schemas.Add (schema);
try {
xvr.Read ();
Assert.Fail ("element mismatch is incorrectly allowed");
} catch (XmlSchemaException) {
}
xml = "<hoge xmlns='urn:foo' />";
xvr = PrepareXmlReader (xml);
xvr.Schemas.Add (schema);
try {
xvr.Read ();
Assert.Fail ("Element in different namespace is incorrectly allowed.");
} catch (XmlSchemaException) {
}
}
示例14: DocUIList
public DocUIList(XmlNode xmlNode, XmlSchemaAnnotated xsdNode, Panel contentpanel, Panel overlaypanel, DynamicForm parentForm, bool horizontal = true)
: base(xmlNode, xsdNode, contentpanel, overlaypanel, parentForm)
{
_optlist = new List<ListItemComponent>();
_parent = xmlNode;
_listpanel = new StackPanel();
_listpanel.Orientation = horizontal ? Orientation.Horizontal : Orientation.Vertical;
XmlSchemaElement schemaEl = xsdNode as XmlSchemaElement;
if (schemaEl != null)
{
XmlSchemaSequence seq = XmlSchemaUtilities.tryGetSequence(schemaEl.ElementSchemaType);
if (seq != null && seq.Items.Count == 1 && seq.Items[0] is XmlSchemaElement)
{
_el = seq.Items[0] as XmlSchemaElement;
//get all elements from current node
foreach (XmlNode node in xmlNode.ChildNodes)
{
ListItemComponent lio = new ListItemComponent(node, _el, _listpanel, overlaypanel, _optlist, parentForm);
_optlist.Add(lio);
}
}
Button add = new Button();
add.Content = "Add item";
add.Click += AddItem;
_listpanel.Children.Add(add);
contentpanel.Children.Add(_listpanel);
}
}
示例15: IsXmlSchemaNamespaceElement
/// <summary>
/// Checks whether the element belongs to the XSD namespace.
/// </summary>
static bool IsXmlSchemaNamespaceElement(XmlSchemaElement element)
{
XmlQualifiedName qualifiedName = element.QualifiedName;
if (qualifiedName != null) {
return IsXmlSchemaNamespace(qualifiedName.Namespace);
}
return false;
}