예제 #1
0
        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);
        }
예제 #2
0
 public bool AddAttribute(SimpleXmlAttribute attribute)
 {
     if (attributes.ContainsKey(attribute.Name))
     {
         return(false);
     }
     attributes.Add(attribute.Name, attribute);
     return(true);
 }
예제 #3
0
        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;
        }