System.Xml.Schema.SchemaCollectionCompiler.CompileComplexType C# (CSharp) Méthode

CompileComplexType() private méthode

private CompileComplexType ( XmlSchemaComplexType complexType ) : void
complexType XmlSchemaComplexType
Résultat void
        private void CompileComplexType(XmlSchemaComplexType complexType) {
            if (complexType.ElementDecl != null) { //already compiled
                return;
            }
            if (complexType.IsProcessing) {
                SendValidationEvent(Res.Sch_TypeCircularRef, complexType);
                return;
            }
            complexType.IsProcessing = true;
            if (complexType.ContentModel != null) { //simpleContent or complexContent
                if (complexType.ContentModel is XmlSchemaSimpleContent) {
                    XmlSchemaSimpleContent simpleContent = (XmlSchemaSimpleContent)complexType.ContentModel;
                    complexType.SetContentType(XmlSchemaContentType.TextOnly);
                    if (simpleContent.Content is XmlSchemaSimpleContentExtension) {
                        CompileSimpleContentExtension(complexType, (XmlSchemaSimpleContentExtension)simpleContent.Content);
                    }
                    else { //simpleContent.Content is XmlSchemaSimpleContentRestriction
                        CompileSimpleContentRestriction(complexType, (XmlSchemaSimpleContentRestriction)simpleContent.Content);
                    }
                }
                else { // complexType.ContentModel is XmlSchemaComplexContent
                    XmlSchemaComplexContent complexContent = (XmlSchemaComplexContent)complexType.ContentModel;
                    if (complexContent.Content is XmlSchemaComplexContentExtension) {
                        CompileComplexContentExtension(complexType, complexContent, (XmlSchemaComplexContentExtension)complexContent.Content);
                    }
                    else { // complexContent.Content is XmlSchemaComplexContentRestriction
                        CompileComplexContentRestriction(complexType, complexContent, (XmlSchemaComplexContentRestriction)complexContent.Content);
                    }
                }
            }
            else { //equals XmlSchemaComplexContent with baseType is anyType
                    complexType.SetBaseSchemaType(XmlSchemaComplexType.AnyType);
                    CompileLocalAttributes(XmlSchemaComplexType.AnyType, complexType, complexType.Attributes, complexType.AnyAttribute, XmlSchemaDerivationMethod.Restriction);
                    complexType.SetDerivedBy(XmlSchemaDerivationMethod.Restriction);
                    complexType.SetContentTypeParticle(CompileContentTypeParticle(complexType.Particle, true));
                    complexType.SetContentType(GetSchemaContentType(complexType, null, complexType.ContentTypeParticle));
            }
            bool hasID = false;
            foreach(XmlSchemaAttribute attribute in complexType.AttributeUses.Values) {
                if (attribute.Use != XmlSchemaUse.Prohibited) {
                    XmlSchemaDatatype datatype = attribute.Datatype;
                    if (datatype != null && datatype.TokenizedType == XmlTokenizedType.ID) {
                        if (hasID) {
                            SendValidationEvent(Res.Sch_TwoIdAttrUses, complexType);
                        }
                        else {
                            hasID = true;
                        }
                    }
                }
            }
            SchemaElementDecl decl = new SchemaElementDecl();
            decl.ContentValidator = CompileComplexContent(complexType);
            decl.SchemaType = complexType;
            decl.IsAbstract = complexType.IsAbstract;
            decl.Datatype = complexType.Datatype;
            decl.Block = complexType.BlockResolved;
            decl.AnyAttribute = complexType.AttributeWildcard;
            foreach(XmlSchemaAttribute attribute in complexType.AttributeUses.Values) {
                if (attribute.Use == XmlSchemaUse.Prohibited) {
                    if (decl.ProhibitedAttributes[attribute.QualifiedName] == null) {
                        decl.ProhibitedAttributes.Add(attribute.QualifiedName, attribute.QualifiedName);
                    }
                }
                else {
                    if (decl.AttDefs[attribute.QualifiedName] == null && attribute.AttDef != null && attribute.AttDef.Name != XmlQualifiedName.Empty && attribute.AttDef != SchemaAttDef.Empty) {
                        decl.AddAttDef(attribute.AttDef);
                    }
                }
            }
            decl.EndAddAttDef();

            complexType.ElementDecl = decl;

            complexType.IsProcessing = false;
        }