private Element ProcessElement(XmlSchemaElement schemaElement, Element parent) { var element = new Element { Name = schemaElement.Name, Type = schemaElement.ElementType == null ? "" : schemaElement.ElementType.GetType().Name, MinOccurs = schemaElement.MinOccurs, MaxOccurs = FixMaxOccurs(schemaElement, parent == null ? "" : parent.Name), Documentation = GetDocumentation(schemaElement.Annotation, schemaElement.Name), RootObject = "Xsd", RootElement = SpecialCaseHandlers.RootElement(parent) }; element.IsAdvanced = SpecialCaseHandlers.IsAdvanced(element, parent); element.SpecialLength = SpecialCaseHandlers.SpecialLength(element, parent); element.Parent = parent ?? FillOutRootElement(element); if (schemaElement.SchemaType != null) { ProcessChildren(schemaElement, element); } if (parent != null) { parent.Elements.Add(element); return(null); } else { return(element); } //will break if moved about the Process* calls. //Need access to parent for those functions to get errorCollector.attributes.* working //FillOutRootElement(parent, element); //XmlSchemaType schemaType = configurationElement.SchemaType; //XmlSchemaComplexType schemaComplexType = schemaType as XmlSchemaComplexType; //XmlSchemaSimpleType schemaSimpleType = schemaType as XmlSchemaSimpleType; }
private void ProcessAttributes(XmlSchemaComplexType schemaComplexType, Element element) { var enumerator = schemaComplexType.AttributeUses.GetEnumerator(); while (enumerator.MoveNext()) { var xmlAttribute = (XmlSchemaAttribute)enumerator.Value; var attribute = new Parts.Attribute { Name = xmlAttribute.Name, Type = xmlAttribute.SchemaTypeName.Name, Default = xmlAttribute.DefaultValue ?? "", Use = xmlAttribute.Use.ToString(), Documentation = GetDocumentation(xmlAttribute.Annotation), Parent = element, }; attribute.IsAdvanced = SpecialCaseHandlers.IsAdvanced(attribute, element); attribute.SpecialLength = SpecialCaseHandlers.SpecialLength(attribute, element); attribute.RootObject = "Xsd"; if (xmlAttribute.AttributeSchemaType.Content.GetType().ToString() == "System.Xml.Schema.XmlSchemaSimpleTypeRestriction") { var xmlRestrication = xmlAttribute.AttributeSchemaType.Content as XmlSchemaSimpleTypeRestriction; if (xmlRestrication != null) { var restriction = new Restriction(); foreach (var facet in xmlRestrication.Facets.Cast <XmlSchemaEnumerationFacet>()) { restriction.Enumerations.Add(facet.Value); } attribute.Restriction = restriction; } } element.Attributes.Add(attribute); } }
public void SpecialLength_TrueFromFalse() { Assert.IsTrue(SpecialCaseHandlers.SpecialLength(TestPart("user"))); }
public void SpecialLength_False() { Assert.IsFalse(SpecialCaseHandlers.SpecialLength(TestPart("proxy"))); }
public void SpecialLength_True() { Assert.IsTrue(SpecialCaseHandlers.SpecialLength(TestPart("true"))); }