//
using System;
using System.Collections;
+using System.CodeDom.Compiler;
using System.IO;
using System.Text;
+using System.Web.Caching;
using System.Web.UI;
using System.Web.Util;
void InitParser (string filename)
{
- //FIXME: use the encoding of the file or the one specified in the machine.config/web.config file.
- StreamReader reader = new StreamReader (filename, Encoding.Default);
+ StreamReader reader = new StreamReader (filename, WebEncoding.FileEncoding);
AspParser parser = new AspParser (filename, reader);
+ reader.Close ();
parser.Error += new ParseErrorHandler (ParseError);
parser.TagParsed += new TagParsedHandler (TagParsed);
parser.TextParsed += new TextParsedHandler (TextParsed);
public Type GetCompiledType ()
{
+ Type type = (Type) HttpRuntime.Cache.Get (tparser.InputFile);
+ if (type != null) {
+ return type;
+ }
+
InitParser (Path.GetFullPath (tparser.InputFile));
DoParse ();
#if DEBUG
BaseCompiler compiler = GetCompilerFromType ();
- return compiler.GetCompiledType ();
+ type = compiler.GetCompiledType ();
+ CacheDependency cd = new CacheDependency ((string[])
+ tparser.Dependencies.ToArray (typeof (string)));
+
+ HttpRuntime.Cache.Insert (tparser.InputFile, type, cd);
+ return type;
}
#if DEBUG
void TextParsed (ILocation location, string text)
{
- if (text.IndexOf ("<%") != -1 && !inScript && !javascript) {
+ if (text.IndexOf ("<%") != -1 && !inScript) {
if (this.text.Length > 0)
FlushText ();
CodeRenderParser r = new CodeRenderParser (text, stack.Builder);
bool ProcessTag (string tagid, TagAttributes atts)
{
+ if ((atts == null || !atts.IsRunAtServer ()) && String.Compare (tagid, "tbody", true) == 0) {
+ // MS completely ignores tbody or, if runat="server", fails when compiling
+ if (stack.Count > 0)
+ return stack.Builder.ChildrenAsProperties;
+
+ return false;
+ }
+
ControlBuilder parent = stack.Builder;
ControlBuilder builder = null;
BuilderLocation bl = null;
}
if (builder == null && atts != null && atts.IsRunAtServer ()) {
+ 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) {
bool CloseControl (string tagid)
{
ControlBuilder current = stack.Builder;
+ if (String.Compare (tagid, "tbody", true) == 0) {
+ if (!current.ChildrenAsProperties) {
+ try {
+ TextParsed (location, location.PlainText);
+ FlushText ();
+ } catch {}
+ }
+ return true;
+ }
+
string btag = current.TagName;
if (0 != String.Compare (tagid, btag, true))
return false;
return;
if (String.Compare (lang, tparser.Language, true) != 0) {
- // FIXME: throw the same exception as MS
- throw new Exception ("Trying to mix " + tparser.Language + " and " +
- lang + ".");
+ throw new ParseException (Location,
+ String.Format ("Trying to mix language '{0}' and '{1}'.",
+ tparser.Language, lang));
}
}
// Used to get CodeRender tags in attribute values