Exemplo n.º 1
0
        /// <summary>
        /// Traverses a complex element.
        /// </summary>
        /// <param name="element">The current element.</param>
        /// <param name="type">The current element type.</param>
        /// <param name="name">The element name.</param>
        /// <param name="typeName">The element type name, that is, name + typeNaming.</param>
        /// <param name="parent">The parent of the element received.</param>
        /// <returns>The IVisitableComponent to add to the composite parent.</returns>
        private IVisitableComponent RecurseElement(XmlSchemaElement element, XmlSchemaComplexType type,
                                                   string name, string typeName, BaseSchemaTypedElement parent)
        {
            VisitableElementComplexType result =
                new VisitableElementComplexType(element, type, name, typeName, parent);

            // Traverse all the attributes of the complex type.
            foreach (XmlSchemaObject obj in type.Attributes)
            {
                if (obj is XmlSchemaAttribute)
                {
                    result.Add(Build(obj as XmlSchemaAttribute, result));
                }
            }

            // We only take into account the Choice and Sequence subgroups.
            if (type.Particle is XmlSchemaGroupBase && !(type.Particle is XmlSchemaAll))
            {
                XmlSchemaGroupBase group = type.Particle as XmlSchemaGroupBase;
                foreach (XmlSchemaObject item in group.Items)
                {
                    if (item is XmlSchemaElement)
                    {
                        result.Add(Build(item as XmlSchemaElement, result));
                    }
                }
            }
            return(result);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Default constructor.
 /// </summary>
 /// <param name="element">The schema element.</param>
 /// <param name="name">The name the element will have.</param>
 /// <param name="parent">The parent of the element.</param>
 public VisitableElementIntrinsicType(XmlSchemaElement element, string name,
                                      BaseSchemaTypedElement parent) : base(element, null, name, string.Empty, parent)
 {
     if (element.SchemaTypeName.Namespace != XmlSchema.Namespace)
     {
         throw new ArgumentException("The element doesn't have an intrinsic XSD type.");
     }
 }
Exemplo n.º 3
0
 /// <summary>
 /// Default constructor.
 /// </summary>
 /// <param name="attribute">The schema attribute.</param>
 /// <param name="name">The name the element will have.</param>
 /// <param name="parent">The parent of the element.</param>
 public VisitableAttributeIntrinsicType(XmlSchemaAttribute attribute,
                                        string name, BaseSchemaTypedElement parent) :
     base(attribute, null, name, string.Empty, parent)
 {
     if (attribute.SchemaTypeName.Namespace != XmlSchema.Namespace)
     {
         throw new ArgumentException("The attribute doesn't have an intrinsic XSD type.");
     }
 }
Exemplo n.º 4
0
 /// <summary>
 /// Protected constructor for use by the descendents.
 /// </summary>
 /// <param name="element">The schema object.</param>
 /// <param name="type">The schema type of the object.</param>
 /// <param name="name">The name the element will have.</param>
 /// <param name="typeName">The type name, which can be different from the
 /// schema type name because of TypeNaming conventions.</param>
 /// <param name="parent">The parent of the element.</param>
 protected BaseSchemaTypedElement(XmlSchemaObject element, XmlSchemaType type,
                                  string name, string typeName, BaseSchemaTypedElement parent)
 {
     _schemaobject = element;
     _name         = name;
     _typename     = typeName;
     _schematype   = type;
     _parent       = parent;
 }
Exemplo n.º 5
0
        /// <summary>
        /// Builds an IVisitableComponent with the element passed.
        /// </summary>
        /// <param name="element">The element to use to build the visitable component.</param>
        /// <param name="parent">The parent element of the visitable component to build.</param>
        /// <returns>The visitable component.</returns>
        /// <remarks>If element type is a named complex type, the component typeName will depend on the IterationType
        /// selected in the configuration. So it IterationType.ComplexElements is selected, the typeName will
        /// be the element name plus the TypeNaming convention specified. Else, the ComplexType name is used.
        /// If it is a simple type, the simple type name is used. If the type is unnamed, the element name
        /// plus the TypeNaming is used.
        /// </remarks>
        private IVisitableComponent Build(XmlSchemaElement element, BaseSchemaTypedElement parent)
        {
            if (!element.SchemaTypeName.IsEmpty)
            {
                if (element.SchemaTypeName.Namespace == XmlSchema.Namespace)
                {
                    return(new VisitableElementIntrinsicType(element, element.Name, parent));
                }
                else
                {
                    foreach (XmlSchemaObject item in _context.Items)
                    {
                        if (item is XmlSchemaType &&
                            ((XmlSchemaType)item).Name == element.SchemaTypeName.Name)
                        {
                            if (item is XmlSchemaSimpleType)
                            {
                                XmlSchemaSimpleType st = item as XmlSchemaSimpleType;
                                return(new VisitableElementSimpleType(element, st, element.Name, st.Name, parent));
                            }
                            else
                            {
                                XmlSchemaComplexType ct = item as XmlSchemaComplexType;
                                if (_config.Iteration == IterationType.ComplexType)
                                {
                                    return(RecurseElement(element, ct, element.Name, ct.Name, parent));
                                }
                                else
                                {
                                    return(RecurseElement(element, ct, element.Name, element.Name +
                                                          _config.TypeNaming, parent));
                                }
                            }
                        }
                    }
                }
            }
            else if (element.SchemaType is XmlSchemaSimpleType)
            {
                return(new VisitableElementSimpleType(element,
                                                      element.SchemaType as XmlSchemaSimpleType, element.Name, element.Name +
                                                      _config.TypeNaming, parent));
            }
            else if (element.SchemaType is XmlSchemaComplexType)
            {
                XmlSchemaComplexType ct = element.SchemaType as XmlSchemaComplexType;
                return(RecurseElement(element, ct, element.Name,
                                      element.Name + _config.TypeNaming, parent));
            }

            return(null);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Builds an IVisitableComponent with the attribute passed.
        /// </summary>
        /// <param name="attribute">The attribute to use to build the visitable component.</param>
        /// <param name="parent">The parent element of the visitable component to build.</param>
        /// <returns>The visitable component.</returns>
        /// <remarks>If attribute type is a named simple type, that will be the typeName used for the component if
        /// IterationType.ComplexType is selected. Otherwise, the same naming convention for unnamed simpletypes is followed.
        /// If the simple type is unnamed, the attribute name plus the TypeNaming is used as the typeName parameter
        /// for component.
        /// </remarks>
        private IVisitableComponent Build(XmlSchemaAttribute attribute, BaseSchemaTypedElement parent)
        {
            if (!attribute.SchemaTypeName.IsEmpty)
            {
                if (attribute.SchemaTypeName.Namespace == XmlSchema.Namespace)
                {
                    return(new VisitableAttributeIntrinsicType(attribute, attribute.Name, parent));
                }
                else
                {
                    foreach (XmlSchemaObject item in _context.Items)
                    {
                        if (item is XmlSchemaSimpleType &&
                            ((XmlSchemaSimpleType)item).Name == attribute.SchemaTypeName.Name)
                        {
                            XmlSchemaSimpleType st = item as XmlSchemaSimpleType;
                            if (_config.Iteration == IterationType.ComplexType)
                            {
                                return(new VisitableAttributeSimpleType(attribute, st, attribute.Name,
                                                                        st.Name, parent));
                            }
                            else
                            {
                                return(new VisitableAttributeSimpleType(attribute, st,
                                                                        attribute.Name, attribute.Name + _config.TypeNaming, parent));
                            }
                        }
                    }
                }
            }
            else
            {
                return(new VisitableAttributeSimpleType(attribute,
                                                        attribute.SchemaType as XmlSchemaSimpleType, attribute.Name,
                                                        attribute.Name + _config.TypeNaming, parent));
            }

            return(null);
        }
Exemplo n.º 7
0
 /// <summary>
 /// Protected constructor for use by the descendents.
 /// </summary>
 /// <param name="attribute">The schema attribute.</param>
 /// <param name="type">The schema type of the object.</param>
 /// <param name="name">The name the element will have.</param>
 /// <param name="typeName">The type name, which can be different from the
 /// schema type name because of TypeNaming conventions.</param>
 /// <param name="parent">The parent of the element.</param>
 protected BaseVisitableAttribute(XmlSchemaAttribute attribute,
                                  XmlSchemaSimpleType type, string name,
                                  string typeName, BaseSchemaTypedElement parent) :
     base(attribute, type, name, typeName, parent)
 {
 }
Exemplo n.º 8
0
 /// <summary>
 /// Default constructor, for use by descendents.
 /// </summary>
 /// <param name="element">The schema element.</param>
 /// <param name="type">The schema type of the object.</param>
 /// <param name="name">The name the element will have.</param>
 /// <param name="typeName">The type name, which can be different from the
 /// schema type name because of TypeNaming conventions.</param>
 /// <param name="parent">The parent of the element.</param>
 protected BaseVisitableElement(XmlSchemaElement element, XmlSchemaType type,
                                string name, string typeName, BaseSchemaTypedElement parent) :
     base(element, type, name, typeName, parent)
 {
 }
Exemplo n.º 9
0
 /// <summary>
 /// Protected constructor for use by the descendents.
 /// </summary>
 /// <param name="element">The schema object.</param>
 /// <param name="type">The schema type of the object.</param>
 /// <param name="name">The name the element will have.</param>
 /// <param name="typeName">The type name, which can be different from the
 /// schema type name because of TypeNaming conventions.</param>
 /// <param name="parent">The parent of the element.</param>
 protected BaseCompositeSchemaElement(XmlSchemaObject element,
                                      XmlSchemaType type, string name, string typeName, BaseSchemaTypedElement parent) :
     base(element, type, name, typeName, parent)
 {
 }
Exemplo n.º 10
0
 /// <summary>
 /// Default constructor.
 /// </summary>
 /// <param name="element">The schema element.</param>
 /// <param name="type">The schema type of the object.</param>
 /// <param name="name">The name the element will have.</param>
 /// <param name="typeName">The type name, which can be different from the
 /// schema type name because of TypeNaming conventions.</param>
 /// <param name="parent">The parent of the element.</param>
 public VisitableElementSimpleType(XmlSchemaElement element,
                                   XmlSchemaSimpleType type, string name, string typeName,
                                   BaseSchemaTypedElement parent) : base(element, type, name, typeName, parent)
 {
 }
 /// <summary>
 /// Default constructor.
 /// </summary>
 /// <param name="element">The schema element.</param>
 /// <param name="type">The schema type of the object.</param>
 /// <param name="name">The name the element will have.</param>
 /// <param name="typeName">The type name, which can be different from the
 /// schema type name because of TypeNaming conventions.</param>
 /// <param name="parent">The parent of the element.</param>
 public VisitableElementComplexType(XmlSchemaObject element,
                                    XmlSchemaComplexType type, string name, string typeName,
                                    BaseSchemaTypedElement parent) : base(element, type, name, typeName, parent)
 {
 }