internal virtual RestrictionFacets ConstructRestriction(DatatypeImplementation datatype, XmlSchemaObjectCollection facets, XmlNameTable nameTable) {
//Datatype is the type on which this method is called
RestrictionFacets derivedRestriction = new RestrictionFacets();
FacetsCompiler facetCompiler = new FacetsCompiler(datatype, derivedRestriction);
foreach(XmlSchemaFacet facet in facets) {
if (facet.Value == null) {
throw new XmlSchemaException(Res.Sch_InvalidFacet, facet);
}
IXmlNamespaceResolver nsmgr = new SchemaNamespaceManager(facet);
switch(facet.FacetType) {
case FacetType.Length:
facetCompiler.CompileLengthFacet(facet);
break;
case FacetType.MinLength:
facetCompiler.CompileMinLengthFacet(facet);
break;
case FacetType.MaxLength:
facetCompiler.CompileMaxLengthFacet(facet);
break;
case FacetType.Pattern:
facetCompiler.CompilePatternFacet(facet as XmlSchemaPatternFacet);
break;
case FacetType.Enumeration:
facetCompiler.CompileEnumerationFacet(facet, nsmgr, nameTable);
break;
case FacetType.Whitespace:
facetCompiler.CompileWhitespaceFacet(facet);
break;
case FacetType.MinInclusive:
facetCompiler.CompileMinInclusiveFacet(facet);
break;
case FacetType.MinExclusive:
facetCompiler.CompileMinExclusiveFacet(facet);
break;
case FacetType.MaxInclusive:
facetCompiler.CompileMaxInclusiveFacet(facet);
break;
case FacetType.MaxExclusive:
facetCompiler.CompileMaxExclusiveFacet(facet);
break;
case FacetType.TotalDigits:
facetCompiler.CompileTotalDigitsFacet(facet);
break;
case FacetType.FractionDigits:
facetCompiler.CompileFractionDigitsFacet(facet);
break;
default:
throw new XmlSchemaException(Res.Sch_UnknownFacet, facet);
}
}
facetCompiler.FinishFacetCompile();
facetCompiler.CompileFacetCombinations();
return derivedRestriction;
}