/// <summary>
/// Parses a document fragment. Processes all controls and directives and adds them to host.
/// </summary>
/// <param name="fragment">The document fragment to parse</param>
/// <returns>The document with all controls, directives and script blocks replaced by placeholders</returns>
public void ParseDocument(string fragment, out Control[] controls, out string designDocument)
{
AspParser parser = InitialiseParser(fragment);
rootParsingObject = new RootParsingObject(host);
openObject = rootParsingObject;
parser.Parse();
if (openObject != rootParsingObject)
{
throw new Exception("The tag " + openObject.TagID + " was left unclosed");
}
object[] objects;
rootParsingObject.BuildObject(out objects, out designDocument);
controls = new Control[objects.Length];
objects.CopyTo(controls, 0);
}