Exemplo n.º 1
0
        private string GetDocumentation(XmlSchemaAnnotation annotation, string elementName = "")
        {
            string documentation = "";

            if (annotation != null)
            {
                foreach (var schemaObject in annotation.Items)
                {
                    var item = (XmlSchemaDocumentation)schemaObject;
                    documentation = CleanAnnotation(item);
                }
            }

            documentation += SpecialCaseHandlers.EnhancedDocumentation(elementName);
            return(documentation);
        }
Exemplo n.º 2
0
        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;
        }
Exemplo n.º 3
0
        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);
            }
        }
Exemplo n.º 4
0
 public void IsAdvanced_True()
 {
     Assert.IsTrue(SpecialCaseHandlers.IsAdvanced(TestPart("debugAgent")));
 }
Exemplo n.º 5
0
 public void IsAdvanced_False()
 {
     Assert.IsFalse(SpecialCaseHandlers.IsAdvanced(TestPart("root")));
 }
Exemplo n.º 6
0
 public void RootElement_False()
 {
     Assert.IsFalse(SpecialCaseHandlers.RootElement(TestPart("proxy")));
 }
Exemplo n.º 7
0
 public void RootElement_True()
 {
     Assert.IsTrue(SpecialCaseHandlers.RootElement(TestPart("service")));
 }
Exemplo n.º 8
0
 public void SpecialLength_False()
 {
     Assert.IsFalse(SpecialCaseHandlers.SpecialLength(TestPart("proxy")));
 }
Exemplo n.º 9
0
 public void SpecialLength_TrueFromFalse()
 {
     Assert.IsTrue(SpecialCaseHandlers.SpecialLength(TestPart("user")));
 }
Exemplo n.º 10
0
 public void SpecialLength_True()
 {
     Assert.IsTrue(SpecialCaseHandlers.SpecialLength(TestPart("true")));
 }