Beispiel #1
0
        internal void GetColumns(ColumnSchemaCollection columnSchemaCollection)
        {
            // The ComplexContent is mutually exclusive of the Particle.  That is, if there is no particle defined for this comlex
            // type then it must have a comlex content description.  Comlex content extends a base class.
            if (this.xmlSchemaComplexType == null)
            {
                // The Comlex Content describes an extension of a base class.
                if (this.xmlSchemaComplexType.ContentModel is XmlSchemaComplexContent)
                {
                    // Strongly type the XmlSchemaContent.
                    XmlSchemaComplexContent xmlSchemaComplexContent = xmlSchemaComplexType.ContentModel as XmlSchemaComplexContent;

                    // A complex content can be derived by extension (adding columns) or restriction (removing columns).  This
                    // section will look for the extensions to the base class.
                    if (xmlSchemaComplexContent.Content is XmlSchemaComplexContentExtension)
                    {
                        // The Complex Content Extension describes a base class and the additional columns that make up a derived
                        // class.  This section will recursively collect the columns from the base class and then parse out the
                        // extra columns in-line.
                        XmlSchemaComplexContentExtension xmlSchemaComplexContentExtension =
                            xmlSchemaComplexContent.Content as XmlSchemaComplexContentExtension;

                        // This will recursively read the columns from the base classes.
                        TypeSchema baseType = this.Schema.GetTypeSchema(xmlSchemaComplexContentExtension.BaseTypeName);
                        baseType.GetColumns(columnSchemaCollection);

                        // The additional columns for this inherited table are found on the in-line in the <sequence> node that follows
                        // the <extension> node.
                        if (xmlSchemaComplexContentExtension.Particle is XmlSchemaSequence)
                        {
                            // Strongly type the XmlSchemaSequence
                            XmlSchemaSequence xmlSchemaSequence = xmlSchemaComplexContentExtension.Particle as XmlSchemaSequence;

                            // Read through the sequence and replace any column from an inherited class with the column in the
                            // derived class.  Also note that the columns are added in alphabetical order to give some amount of
                            // predictability to the way the parameter lists are constructed when there are several layers of
                            // inheritance.
                            foreach (XmlSchemaObject xmlSchemaObject in xmlSchemaSequence.Items)
                            {
                                ColumnSchema columnSchema = new ColumnSchema(this.Schema, xmlSchemaObject);
                                if (columnSchemaCollection.ContainsKey(columnSchema.Name))
                                {
                                    columnSchemaCollection.Remove(columnSchema.Name);
                                }
                                columnSchemaCollection.Add(columnSchema);
                            }
                        }

                        // The Complex Content can also contain attributes that describe columns.
                        foreach (XmlSchemaAttribute xmlSchemaAttribute in xmlSchemaComplexContentExtension.Attributes)
                        {
                            ColumnSchema columnSchema = new ColumnSchema(this.Schema, xmlSchemaAttribute);
                            if (columnSchemaCollection.ContainsKey(columnSchema.Name))
                            {
                                columnSchemaCollection.Remove(columnSchema.Name);
                            }
                            columnSchemaCollection.Add(columnSchema);
                        }
                    }
                }
            }
            else
            {
                // This section will parse the simple particle.  The particle has no inheritiance to evaluate.
                if (xmlSchemaComplexType.Particle is XmlSchemaSequence)
                {
                    // Strongly type the XmlSchemaSequence member.
                    XmlSchemaSequence xmlSchemaSequence = xmlSchemaComplexType.Particle as XmlSchemaSequence;

                    // Each XmlSchemaElement on the Particle describes a column.
                    foreach (XmlSchemaObject xmlSchemaObject in xmlSchemaSequence.Items)
                    {
                        ColumnSchema columnSchema = new ColumnSchema(this.Schema, xmlSchemaObject);
                        if (columnSchemaCollection.ContainsKey(columnSchema.Name))
                        {
                            columnSchemaCollection.Remove(columnSchema.Name);
                        }
                        columnSchemaCollection.Add(columnSchema);
                    }
                }
            }
        }
 public void Add(TypeSchema classSchema)
 {
     this.classList.Add(classSchema.Name, classSchema);
 }