private XmlSchemaParticle CannonicalizeGroupRef(XmlSchemaGroupRef groupRef, bool root, bool substitution)
{
XmlSchemaGroup redefined;
if (groupRef.Redefined != null)
{
redefined = groupRef.Redefined;
}
else
{
redefined = (XmlSchemaGroup) this.schema.Groups[groupRef.RefName];
}
if (redefined == null)
{
base.SendValidationEvent("Sch_UndefGroupRef", groupRef.RefName.ToString(), groupRef);
return XmlSchemaParticle.Empty;
}
if (redefined.CanonicalParticle == null)
{
this.CompileGroup(redefined);
}
if (redefined.CanonicalParticle == XmlSchemaParticle.Empty)
{
return XmlSchemaParticle.Empty;
}
XmlSchemaGroupBase canonicalParticle = (XmlSchemaGroupBase) redefined.CanonicalParticle;
if (canonicalParticle is XmlSchemaAll)
{
if (!root)
{
base.SendValidationEvent("Sch_AllRefNotRoot", "", groupRef);
return XmlSchemaParticle.Empty;
}
if ((groupRef.MinOccurs != 1M) || (groupRef.MaxOccurs != 1M))
{
base.SendValidationEvent("Sch_AllRefMinMax", groupRef);
return XmlSchemaParticle.Empty;
}
}
else if ((canonicalParticle is XmlSchemaChoice) && (canonicalParticle.Items.Count == 0))
{
if (groupRef.MinOccurs != 0M)
{
base.SendValidationEvent("Sch_EmptyChoice", groupRef, XmlSeverityType.Warning);
}
return XmlSchemaParticle.Empty;
}
XmlSchemaGroupBase base3 = (canonicalParticle is XmlSchemaSequence) ? ((XmlSchemaGroupBase) new XmlSchemaSequence()) : ((canonicalParticle is XmlSchemaChoice) ? ((XmlSchemaGroupBase) new XmlSchemaChoice()) : ((XmlSchemaGroupBase) new XmlSchemaAll()));
base3.MinOccurs = groupRef.MinOccurs;
base3.MaxOccurs = groupRef.MaxOccurs;
for (int i = 0; i < canonicalParticle.Items.Count; i++)
{
base3.Items.Add((XmlSchemaParticle) canonicalParticle.Items[i]);
}
groupRef.SetParticle(base3);
return base3;
}