private Prepare ( |
||
schema | ||
cleanup | bool | |
return | void |
internal void Prepare(XmlSchema schema, bool cleanup) {
if (schemasToCompile[schema] != null) {
return;
}
schemasToCompile.Add(schema, schema);
foreach (XmlSchemaElement element in schema.Elements.Values) {
if (cleanup) {
CleanupElement(element);
}
AddToTable(elements, element.QualifiedName, element);
}
foreach (XmlSchemaAttribute attribute in schema.Attributes.Values) {
if (cleanup) {
CleanupAttribute(attribute);
}
AddToTable(attributes, attribute.QualifiedName, attribute);
}
foreach (XmlSchemaGroup group in schema.Groups.Values) {
if (cleanup) {
CleanupGroup(group);
}
AddToTable(groups, group.QualifiedName, group);
}
foreach (XmlSchemaAttributeGroup attributeGroup in schema.AttributeGroups.Values) {
if (cleanup) {
CleanupAttributeGroup(attributeGroup);
}
AddToTable(attributeGroups, attributeGroup.QualifiedName, attributeGroup);
}
foreach (XmlSchemaType type in schema.SchemaTypes.Values) {
if (cleanup) {
XmlSchemaComplexType ct = type as XmlSchemaComplexType;
if (ct != null) {
CleanupComplexType(ct);
}
else {
CleanupSimpleType(type as XmlSchemaSimpleType);
}
}
AddToTable(schemaTypes, type.QualifiedName, type);
}
foreach (XmlSchemaNotation notation in schema.Notations.Values) {
AddToTable(notations, notation.QualifiedName, notation);
}
foreach (XmlSchemaIdentityConstraint ic in schema.IdentityConstraints.Values) {
AddToTable(identityConstraints, ic.QualifiedName, ic);
}
}
public void Compile() { if (!this.isCompiled) { if (this.schemas.Count == 0) { this.ClearTables(); this.cachedCompiledInfo = new SchemaInfo(); this.isCompiled = true; this.compileAll = false; } else { lock (this.InternalSyncObject) { if (!this.isCompiled) { Compiler compiler = new Compiler(this.nameTable, this.eventHandler, this.schemaForSchema, this.compilationSettings); SchemaInfo schemaCompiledInfo = new SchemaInfo(); int index = 0; if (!this.compileAll) { compiler.ImportAllCompiledSchemas(this); } try { XmlSchema buildInSchema = Preprocessor.GetBuildInSchema(); index = 0; while (index < this.schemas.Count) { XmlSchema byIndex = (XmlSchema) this.schemas.GetByIndex(index); Monitor.Enter(byIndex); if (!byIndex.IsPreprocessed) { this.SendValidationEvent(new XmlSchemaException("Sch_SchemaNotPreprocessed", string.Empty), XmlSeverityType.Error); this.isCompiled = false; goto Label_01BA; } if (byIndex.IsCompiledBySet) { if (!this.compileAll) { goto Label_00FD; } if (byIndex == buildInSchema) { compiler.Prepare(byIndex, false); goto Label_00FD; } } compiler.Prepare(byIndex, true); Label_00FD: index++; } this.isCompiled = compiler.Execute(this, schemaCompiledInfo); if (this.isCompiled) { if (!this.compileAll) { schemaCompiledInfo.Add(this.cachedCompiledInfo, this.eventHandler); } this.compileAll = false; this.cachedCompiledInfo = schemaCompiledInfo; } } finally { if (index == this.schemas.Count) { index--; } for (int i = index; i >= 0; i--) { XmlSchema schema3 = (XmlSchema) this.schemas.GetByIndex(i); if (schema3 == Preprocessor.GetBuildInSchema()) { Monitor.Exit(schema3); } else { schema3.IsCompiledBySet = this.isCompiled; Monitor.Exit(schema3); } } } } Label_01BA:; } } } }