diff options
author | Gonzalo Paniagua Javier <gonzalo.mono@gmail.com> | 2003-04-30 23:42:58 +0400 |
---|---|---|
committer | Gonzalo Paniagua Javier <gonzalo.mono@gmail.com> | 2003-04-30 23:42:58 +0400 |
commit | b25312c41b0c129d4d340d1adbb1e2903a0f46a1 (patch) | |
tree | 8c5e86cf821be2d6137cf662ba1019de290ec9eb | |
parent | 792f08f69ecfa7eacfaefcf9a011495b845d7b45 (diff) |
2003-04-30 Gonzalo Paniagua Javier <gonzalo@ximian.com>
* AspGenerator.cs: handle code render syntax in tag attributes.
* AspParser.cs: the constructor now takes a TextReader.
* TemplateControlCompiler.cs: removed comment.
svn path=/trunk/mcs/; revision=14166
4 files changed, 67 insertions, 7 deletions
diff --git a/mcs/class/System.Web/System.Web.Compilation/AspGenerator.cs b/mcs/class/System.Web/System.Web.Compilation/AspGenerator.cs index df8970c5d00..ae1b03a4d59 100644 --- a/mcs/class/System.Web/System.Web.Compilation/AspGenerator.cs +++ b/mcs/class/System.Web/System.Web.Compilation/AspGenerator.cs @@ -115,11 +115,6 @@ namespace System.Web.Compilation BaseCompiler compiler = GetCompilerFromType (); - /* - IndentedTextWriter tw = new IndentedTextWriter (Console.Out, " "); - generator.GenerateCodeFromCompileUnit (unit, tw, new CodeGeneratorOptions()); - tw.Close (); - */ return compiler.GetCompiledType (); } @@ -191,6 +186,14 @@ namespace System.Web.Compilation void TextParsed (ILocation location, string text) { + if (text.IndexOf ("<%") != -1) { + if (this.text.Length > 0) + FlushText (); + CodeRenderParser r = new CodeRenderParser (text, stack.Builder); + r.AddChildren (); + return; + } + this.text.Append (text); //PrintLocation (location); } @@ -294,6 +297,54 @@ namespace System.Web.Compilation public ILocation Location { get { return location; } } + + // Used to get CodeRender tags in attribute values + class CodeRenderParser + { + string str; + ControlBuilder builder; + + public CodeRenderParser (string str, ControlBuilder builder) + { + this.str = str; + this.builder = builder; + } + + public void AddChildren () + { + int index = str.IndexOf ("<%"); + if (index > 0) { + TextParsed (null, str.Substring (0, index)); + str = str.Substring (index); + } + + AspParser parser = new AspParser ("@@inner_string@@", new StringReader (str)); + parser.Error += new ParseErrorHandler (ParseError); + parser.TagParsed += new TagParsedHandler (TagParsed); + parser.TextParsed += new TextParsedHandler (TextParsed); + parser.Parse (); + } + + void TagParsed (ILocation location, TagType tagtype, string tagid, TagAttributes attributes) + { + if (tagtype == TagType.CodeRender) + builder.AppendSubBuilder (new CodeRenderBuilder (tagid, false, location)); + else if (tagtype == TagType.CodeRenderExpression) + builder.AppendSubBuilder (new CodeRenderBuilder (tagid, true, location)); + else + builder.AppendLiteralString (location.PlainText); + } + + void TextParsed (ILocation location, string text) + { + builder.AppendLiteralString (text); + } + + void ParseError (ILocation location, string message) + { + throw new ParseException (location, message); + } + } } } diff --git a/mcs/class/System.Web/System.Web.Compilation/AspParser.cs b/mcs/class/System.Web/System.Web.Compilation/AspParser.cs index 05f62357aef..21a9eb8686d 100644 --- a/mcs/class/System.Web/System.Web.Compilation/AspParser.cs +++ b/mcs/class/System.Web/System.Web.Compilation/AspParser.cs @@ -27,7 +27,7 @@ namespace System.Web.Compilation string fileText; string verbatimID; - public AspParser (string filename, StreamReader input) + public AspParser (string filename, TextReader input) { this.filename = filename; fileText = input.ReadToEnd (); diff --git a/mcs/class/System.Web/System.Web.Compilation/ChangeLog b/mcs/class/System.Web/System.Web.Compilation/ChangeLog index 7dc96f81ab3..a47d68099d4 100644 --- a/mcs/class/System.Web/System.Web.Compilation/ChangeLog +++ b/mcs/class/System.Web/System.Web.Compilation/ChangeLog @@ -1,5 +1,13 @@ 2003-04-30 Gonzalo Paniagua Javier <gonzalo@ximian.com> + * AspGenerator.cs: handle code render syntax in tag attributes. + + * AspParser.cs: the constructor now takes a TextReader. + + * TemplateControlCompiler.cs: removed comment. + +2003-04-30 Gonzalo Paniagua Javier <gonzalo@ximian.com> + * TemplateControlCompiler.cs: added support for data bound properties. 2003-04-30 Gonzalo Paniagua Javier <gonzalo@ximian.com> diff --git a/mcs/class/System.Web/System.Web.Compilation/TemplateControlCompiler.cs b/mcs/class/System.Web/System.Web.Compilation/TemplateControlCompiler.cs index 1e6de5a897e..d4c2e9e2ac5 100644 --- a/mcs/class/System.Web/System.Web.Compilation/TemplateControlCompiler.cs +++ b/mcs/class/System.Web/System.Web.Compilation/TemplateControlCompiler.cs @@ -14,6 +14,7 @@ using System.Drawing; using System.Globalization; using System.Reflection; using System.Text; +using System.Web; using System.Web.UI; namespace System.Web.Compilation @@ -766,7 +767,7 @@ namespace System.Web.Compilation void CreateApplicationInstance () { CodeMemberProperty prop = new CodeMemberProperty (); - Type appType = typeof (HttpApplication);//FIXME: uncomment HttpApplicationFactory.AppType; + Type appType = typeof (HttpApplication); prop.Type = new CodeTypeReference (appType); prop.Name = "ApplicationInstance"; prop.Attributes = MemberAttributes.Family | MemberAttributes.Final; |