Ejemplo n.º 1
0
 /// <summary>
 /// Creates a description of a constructor of a class.
 /// </summary>
 /// <param name="classSchema">A description of a type.</param>
 public ConstructorSchema(ClassSchema classSchema)
 {
     // Initialize the object
     this.argumentSchemaList = new List <ArgumentSchema>();
     this.snippetSchemaList  = new List <SnippetSchema>();
     this.classSchema        = classSchema;
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates a description of a constructor of a class using the XML Schema extensions.
        /// </summary>
        /// <param name="classSchema">A description of a type.</param>
        /// <param name="xmlNode">Extensions to the XML Schema specification.</param>
        public ConstructorSchema(ClassSchema classSchema, XmlNode xmlNode)
        {
            // Initialize the object
            this.argumentSchemaList = new List <ArgumentSchema>();
            this.snippetSchemaList  = new List <SnippetSchema>();
            this.classSchema        = classSchema;

            // Add arguments to the constructor.
            foreach (XmlNode argmentsNode in xmlNode.ChildNodes)
            {
                if (QualifiedName.Arguments == new XmlQualifiedName(argmentsNode.LocalName, argmentsNode.NamespaceURI))
                {
                    foreach (XmlNode argumentNode in argmentsNode.ChildNodes)
                    {
                        if (QualifiedName.Argument == new XmlQualifiedName(argumentNode.LocalName, argumentNode.NamespaceURI))
                        {
                            this.argumentSchemaList.Add(new ArgumentSchema(this, argumentNode));
                        }
                    }
                }
            }

            // Add setters to the constructor.
            foreach (XmlNode childNode in xmlNode.ChildNodes)
            {
                XmlQualifiedName nodeName = new XmlQualifiedName(childNode.LocalName, childNode.NamespaceURI);
                if (nodeName == QualifiedName.Snippet)
                {
                    this.snippetSchemaList.Add(new SnippetSchema(childNode));
                }
                if (nodeName == QualifiedName.Setter)
                {
                    this.snippetSchemaList.Add(new SetterSchema(childNode));
                }
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Create a table schema from the XML Schema specification.
        /// </summary>
        /// <param name="presentationSchema">The data model to which this table belongs.</param>
        /// <param name="xmlSchemaElement">The root of the XmlSchema element that describes the table.</param>
        public PropertySchema(ClassSchema classSchema, XmlSchemaElement xmlSchemaElement)
        {
            // Initialize the object.
            this.classSchema       = classSchema;
            this.isSimpleType      = true;
            this.maxOccurs         = xmlSchemaElement.MaxOccurs;
            this.minOccurs         = xmlSchemaElement.MinOccurs;
            this.name              = xmlSchemaElement.Name;
            this.querySchemaList   = new List <QuerySchema>();
            this.snippetSchemaList = new List <SnippetSchema>();
            this.type              = String.Empty;

            // Initialize the data type from a complex type description.  The complex type can describe either a non-standard XML
            // data type through the unhandled 'DataType' specification, or it can reference a data type that's declared in the
            // schema.
            if (xmlSchemaElement.ElementSchemaType is XmlSchemaComplexType)
            {
                XmlSchemaComplexType xmlSchemaComplexType = xmlSchemaElement.ElementSchemaType as XmlSchemaComplexType;
                if (xmlSchemaComplexType.QualifiedName == QualifiedName.AnyType)
                {
                    foreach (XmlAttribute xmlAttribute in xmlSchemaElement.UnhandledAttributes)
                    {
                        if (QualifiedName.DataType == new XmlQualifiedName(xmlAttribute.LocalName, xmlAttribute.NamespaceURI))
                        {
                            this.isSimpleType = true;
                            this.type         = xmlAttribute.Value;
                        }
                    }
                }
                else
                {
                    this.type         = xmlSchemaComplexType.QualifiedName.ToString();
                    this.isSimpleType = false;
                }
            }

            // Initialize the data type from a simple type description.
            if (xmlSchemaElement.ElementSchemaType is XmlSchemaSimpleType)
            {
                XmlSchemaSimpleType xmlSchemaSimpleType = xmlSchemaElement.ElementSchemaType as XmlSchemaSimpleType;
                this.isSimpleType = true;
                this.type         = xmlSchemaSimpleType.Datatype.ValueType.FullName;
            }

            // This will run through each of the custom fields associated with the element and create fields that will sort, filter
            // and transform the data from the source list into the destination list.
            if (xmlSchemaElement.Annotation != null)
            {
                foreach (XmlSchemaObject xmlSchemaObject in xmlSchemaElement.Annotation.Items)
                {
                    if (xmlSchemaObject is XmlSchemaAppInfo)
                    {
                        XmlSchemaAppInfo xmlSchemaAppInfo = xmlSchemaObject as XmlSchemaAppInfo;
                        foreach (XmlNode xmlNode in xmlSchemaAppInfo.Markup)
                        {
                            XmlQualifiedName nodeName = new XmlQualifiedName(xmlNode.LocalName, xmlNode.NamespaceURI);
                            if (QualifiedName.Where == nodeName)
                            {
                                this.querySchemaList.Add(new WhereSchema(this, xmlNode));
                            }
                            if (QualifiedName.Select == nodeName)
                            {
                                this.querySchemaList.Add(new SelectSchema(this, xmlNode));
                            }
                            if (QualifiedName.OrderBy == nodeName)
                            {
                                this.querySchemaList.Add(new OrderBySchema(this, xmlNode));
                            }
                            if (QualifiedName.Snippet == nodeName)
                            {
                                this.snippetSchemaList.Add(new SnippetSchema(xmlNode));
                            }
                            if (QualifiedName.Setter == nodeName)
                            {
                                this.snippetSchemaList.Add(new SetterSchema(xmlNode));
                            }
                        }
                    }
                }
            }
        }