private SimpleXmlAttribute ParseAttribute(XmlSchemaAttribute attribute) { var simpleAttribute = new SimpleXmlAttribute(); simpleAttribute.Name = attribute.QualifiedName.Name; simpleAttribute.Namespace = attribute.QualifiedName.Namespace; var type = attribute.AttributeSchemaType; var possibleValues = new List <string>(); if (type != null && type.Content is XmlSchemaSimpleTypeRestriction) { var restriction = (XmlSchemaSimpleTypeRestriction)type.Content; foreach (var facet in restriction.Facets) { if (facet is XmlSchemaEnumerationFacet) { possibleValues.Add(((XmlSchemaEnumerationFacet)facet).Value); } } } if (possibleValues.Count > 0) { simpleAttribute.PossibleValues = possibleValues; } return(simpleAttribute); }
public bool AddAttribute(SimpleXmlAttribute attribute) { if (attributes.ContainsKey(attribute.Name)) { return(false); } attributes.Add(attribute.Name, attribute); return(true); }
private SimpleXmlAttribute ParseAttribute(XmlSchemaAttribute attribute) { var simpleAttribute = new SimpleXmlAttribute(); simpleAttribute.Name = attribute.QualifiedName.Name; simpleAttribute.Namespace = attribute.QualifiedName.Namespace; var type = attribute.AttributeSchemaType; var possibleValues = new List<string>(); if (type != null && type.Content is XmlSchemaSimpleTypeRestriction) { var restriction = (XmlSchemaSimpleTypeRestriction)type.Content; foreach (var facet in restriction.Facets) { if (facet is XmlSchemaEnumerationFacet) { possibleValues.Add(((XmlSchemaEnumerationFacet)facet).Value); } } } if (possibleValues.Count > 0) simpleAttribute.PossibleValues = possibleValues; return simpleAttribute; }