void TagParsed (ILocation location, TagType tagtype, string tagid, TagAttributes attributes)
{
bool tagIgnored;
this.location = new Location (location);
if (tparser != null)
tparser.Location = location;
if (text.Length != 0) {
bool ignoreEmptyString = lastTag == TagType.CodeRender;
#if NET_4_0
ignoreEmptyString |= lastTag == TagType.CodeRenderEncode;
#endif
FlushText (ignoreEmptyString);
}
if (0 == String.Compare (tagid, "script", true, Helpers.InvariantCulture)) {
bool in_script = (inScript || ignore_text);
if (in_script) {
if (ProcessScript (tagtype, attributes))
return;
} else
if (ProcessScript (tagtype, attributes))
return;
}
lastTag = tagtype;
switch (tagtype) {
case TagType.Directive:
if (tagid.Length == 0)
tagid = tparser.DefaultDirectiveName;
tparser.AddDirective (tagid, attributes.GetDictionary (null));
break;
case TagType.Tag:
if (ProcessTag (location, tagid, attributes, tagtype, out tagIgnored)) {
if (!tagIgnored)
useOtherTags = true;
break;
}
if (useOtherTags) {
stack.Builder.EnsureOtherTags ();
stack.Builder.OtherTags.Add (tagid);
}
{
string plainText = location.PlainText;
if (!ProcessTagsInAttributes (location, tagid, attributes, TagType.Tag))
TextParsed (location, ChopOffTagStart (location, plainText, tagid));
}
break;
case TagType.Close:
bool notServer = (useOtherTags && TryRemoveTag (tagid, stack.Builder.OtherTags));
if (!notServer && CloseControl (tagid))
break;
TextParsed (location, location.PlainText);
break;
case TagType.SelfClosing:
int count = stack.Count;
if (!ProcessTag (location, tagid, attributes, tagtype, out tagIgnored) && !tagIgnored) {
string plainText = location.PlainText;
if (!ProcessTagsInAttributes (location, tagid, attributes, TagType.SelfClosing))
TextParsed (location, ChopOffTagStart (location, plainText, tagid));
} else if (stack.Count != count) {
CloseControl (tagid);
}
break;
case TagType.DataBinding:
case TagType.CodeRenderExpression:
case TagType.CodeRender:
#if NET_4_0
case TagType.CodeRenderEncode:
#endif
if (isApplication)
throw new ParseException (location, "Invalid content for application file.");
ProcessCode (tagtype, tagid, location);
break;
case TagType.Include:
if (isApplication)
throw new ParseException (location, "Invalid content for application file.");
string file = attributes ["virtual"] as string;
bool isvirtual = (file != null);
if (!isvirtual)
file = attributes ["file"] as string;
if (isvirtual) {
bool parsed = false;
VirtualPathProvider vpp = HostingEnvironment.VirtualPathProvider;
if (vpp.FileExists (file)) {
VirtualFile vf = vpp.GetFile (file);
if (vf != null) {
Parse (vf.Open (), file, true);
parsed = true;
}
}
if (!parsed)
Parse (tparser.MapPath (file), true);
} else {
string includeFilePath = GetIncludeFilePath (tparser.ParserDir, file);
CheckIfIncludeFileIsSecure (includeFilePath);
tparser.PushIncludeDir (Path.GetDirectoryName (includeFilePath));
try {
Parse (includeFilePath, true);
} finally {
tparser.PopIncludeDir ();
}
}
break;
default:
break;
}
//PrintLocation (location);
}