Exemple #1
0
        public override bool Equals(object obj)
        {
            if (obj is KeySchema)
            {
                KeySchema keySchema = obj as KeySchema;
                return(this.QualifiedName.Equals(keySchema.QualifiedName));
            }

            return(false);
        }
Exemple #2
0
        /// <summary>
        /// The constraints must be initialized after the tables are constructed.
        /// </summary>
        /// <param name="xmlSchema"></param>
        private void InitializeConstraints(XmlSchema xmlSchema)
        {
            // This will scan each of the top-level element of the schema looking for Unique and Key constraints.  These
            // constraints must be defined before the KeyRef constraints are created because the KeyRef constraints reference the
            // Unique and Key constraints.
            foreach (XmlSchemaObject xmlSchemaObject in xmlSchema.Items)
            {
                if (xmlSchemaObject is XmlSchemaElement)
                {
                    XmlSchemaElement xmlSchemaElement = xmlSchemaObject as XmlSchemaElement;
                    foreach (XmlSchemaIdentityConstraint xmlSchemaIdentityConstraint in xmlSchemaElement.Constraints)
                    {
                        if (xmlSchemaIdentityConstraint is XmlSchemaUnique)
                        {
                            UniqueSchema uniqueSchema = new UniqueSchema(this, xmlSchemaIdentityConstraint as XmlSchemaUnique);
                            uniqueSchema.Selector.Constraints.Add(uniqueSchema);
                        }
                        if (xmlSchemaIdentityConstraint is XmlSchemaKey)
                        {
                            KeySchema keySchema = new KeySchema(this, xmlSchemaIdentityConstraint as XmlSchemaKey);
                            keySchema.Selector.Constraints.Add(keySchema);
                        }
                    }
                }
            }

            // Once the Key and Unique constraints are described, the schema can be scanned for Keyref schemas.  The 'Refer'
            // property of the KeyrefSchema objects points to the KeySchema or UniqueSchema.
            foreach (XmlSchemaObject xmlSchemaObject in xmlSchema.Items)
            {
                if (xmlSchemaObject is XmlSchemaElement)
                {
                    XmlSchemaElement xmlSchemaElement = xmlSchemaObject as XmlSchemaElement;
                    foreach (XmlSchemaIdentityConstraint xmlSchemaIdentityConstraint in xmlSchemaElement.Constraints)
                    {
                        if (xmlSchemaIdentityConstraint is XmlSchemaKeyref)
                        {
                            KeyrefSchema keyrefSchema = new KeyrefSchema(this, xmlSchemaIdentityConstraint as XmlSchemaKeyref);
                            keyrefSchema.Selector.Constraints.Add(keyrefSchema);
                        }
                    }
                }
            }
        }