bool ProcessTag (ILocation location, string tagid, TagAttributes atts, TagType tagtype, out bool ignored)
{
ignored = false;
if (isApplication) {
if (String.Compare (tagid, "object", true, Helpers.InvariantCulture) != 0)
throw new ParseException (location, "Invalid tag for application file.");
}
ControlBuilder parent = stack.Builder;
ControlBuilder builder = null;
if (parent != null && parent.ControlType == typeof (HtmlTable) &&
(String.Compare (tagid, "thead", true, Helpers.InvariantCulture) == 0 ||
String.Compare (tagid, "tbody", true, Helpers.InvariantCulture) == 0)) {
ignored = true;
return true;
}
IDictionary htable = (atts != null) ? atts.GetDictionary (null) : emptyHash;
if (stack.Count > 1) {
try {
builder = parent.CreateSubBuilder (tagid, htable, null, tparser, location);
} catch (TypeLoadException e) {
throw new ParseException (Location, "Type not found.", e);
} catch (Exception e) {
throw new ParseException (Location, e.Message, e);
}
}
bool runatServer = atts != null && atts.IsRunAtServer ();
if (builder == null && runatServer) {
string id = htable ["id"] as string;
if (id != null && !CodeGenerator.IsValidLanguageIndependentIdentifier (id))
throw new ParseException (Location, "'" + id + "' is not a valid identifier");
try {
builder = RootBuilder.CreateSubBuilder (tagid, htable, null, tparser, location);
} catch (TypeLoadException e) {
throw new ParseException (Location, "Type not found.", e);
} catch (HttpException e) {
CompilationException inner = e.InnerException as CompilationException;
if (inner != null)
throw inner;
throw new ParseException (Location, e.Message, e);
} catch (Exception e) {
throw new ParseException (Location, e.Message, e);
}
}
if (builder == null)
return false;
// This is as good as we can do for now - if the parsed location contains
// both expressions and code render blocks then we're out of luck...
string plainText = location.PlainText;
if (!runatServer && plainText.IndexOf ("<%$") == -1&& plainText.IndexOf ("<%") > -1)
return false;
PageParserFilter pfilter = PageParserFilter;
if (pfilter != null && !pfilter.AllowControl (builder.ControlType, builder))
throw new ParseException (Location, "Control type '" + builder.ControlType + "' not allowed.");
if (!OtherControlsAllowed (builder))
throw new ParseException (Location, "Only Content controls are allowed directly in a content page that contains Content controls.");
builder.Location = location;
builder.ID = htable ["id"] as string;
if (typeof (HtmlForm).IsAssignableFrom (builder.ControlType)) {
if (inForm)
throw new ParseException (location, "Only one <form> allowed.");
inForm = true;
}
if (builder.HasBody () && !(builder is ObjectTagBuilder)) {
if (builder is TemplateBuilder) {
// push the id list
}
stack.Push (builder, location);
} else {
if (!isApplication && builder is ObjectTagBuilder) {
ObjectTagBuilder ot = (ObjectTagBuilder) builder;
if (ot.Scope != null && ot.Scope.Length > 0)
throw new ParseException (location, "Scope not allowed here");
if (tagtype == TagType.Tag) {
stack.Push (builder, location);
return true;
}
}
parent.AppendSubBuilder (builder);
builder.CloseControl ();
}
return true;
}