public ContentValidator Finish(bool useDFA)
{
if (this.contentNode == null)
{
if (base.ContentType != XmlSchemaContentType.Mixed)
{
return ContentValidator.Empty;
}
bool isOpen = base.IsOpen;
if (!base.IsOpen)
{
return ContentValidator.TextOnly;
}
return ContentValidator.Any;
}
InteriorNode parent = new SequenceNode {
LeftChild = this.contentNode
};
LeafNode node2 = new LeafNode(this.positions.Add(this.symbols.AddName(XmlQualifiedName.Empty, null), null));
parent.RightChild = node2;
this.contentNode.ExpandTree(parent, this.symbols, this.positions);
int count = this.symbols.Count;
int num = this.positions.Count;
BitSet firstpos = new BitSet(num);
BitSet lastpos = new BitSet(num);
BitSet[] followpos = new BitSet[num];
for (int i = 0; i < num; i++)
{
followpos[i] = new BitSet(num);
}
parent.ConstructPos(firstpos, lastpos, followpos);
if (this.minMaxNodesCount > 0)
{
BitSet set3;
BitSet[] minmaxFollowPos = this.CalculateTotalFollowposForRangeNodes(firstpos, followpos, out set3);
if (this.enableUpaCheck)
{
this.CheckCMUPAWithLeafRangeNodes(this.GetApplicableMinMaxFollowPos(firstpos, set3, minmaxFollowPos));
for (int j = 0; j < num; j++)
{
this.CheckCMUPAWithLeafRangeNodes(this.GetApplicableMinMaxFollowPos(followpos[j], set3, minmaxFollowPos));
}
}
return new RangeContentValidator(firstpos, followpos, this.symbols, this.positions, node2.Pos, base.ContentType, parent.LeftChild.IsNullable, set3, this.minMaxNodesCount);
}
int[][] transitionTable = null;
if (!this.symbols.IsUpaEnforced)
{
if (this.enableUpaCheck)
{
this.CheckUniqueParticleAttribution(firstpos, followpos);
}
}
else if (useDFA)
{
transitionTable = this.BuildTransitionTable(firstpos, followpos, node2.Pos);
}
if (transitionTable != null)
{
return new DfaContentValidator(transitionTable, this.symbols, base.ContentType, base.IsOpen, parent.LeftChild.IsNullable);
}
return new NfaContentValidator(firstpos, followpos, this.symbols, this.positions, node2.Pos, base.ContentType, base.IsOpen, parent.LeftChild.IsNullable);
}