Files
mono/mcs/class/System.Web/System.Web.Compilation/PageCompiler.cs
T
Gonzalo Paniagua Javier f2e90236bb 2002-09-28 Gonzalo Paniagua Javier <[email protected]>
* list: added PageHandlerFactory.

	* System.Web/HttpApplication.cs:
	* System.Web/HttpApplicationFactory.cs:
	* System.Web/HttpRequest.cs:
	* System.Web/HttpRuntime.cs:
	* System.Web.Compilation/AspElements.cs:
	* System.Web.Compilation/AspGenerator.cs:
	* System.Web.Compilation/AspParser.cs:
	* System.Web.Compilation/PageCompiler.cs:
	* System.Web.Compilation/TemplateFactory.cs: Modified file.
	* System.Web.Configuration/HttpCapabilitiesBase.cs:
	* System.Web.Hosting/SimpleWorkerRequest.cs:
	* System.Web.UI/PageHandlerFactory.cs:
	* System.Web.UI/PageParser.cs:
	* System.Web.UI/TemplateControlParser.cs: we are now able to compile
	pages and use HttpApplication, HttpRuntime and SimpleWorkerRequest.

svn path=/trunk/mcs/; revision=7880
2002-09-28 07:44:14 +00:00

53 lines
1.3 KiB
C#

//
// System.Web.Compilation.PageCompiler
//
// Authors:
// Gonzalo Paniagua Javier ([email protected])
//
// (C) 2002 Ximian, Inc (http://www.ximian.com)
//
using System;
using System.IO;
using System.Web.UI;
namespace System.Web.Compilation
{
class PageCompiler
{
private PageParser pageParser;
internal PageCompiler (PageParser pageParser)
{
this.pageParser = pageParser;
}
public static Type CompilePageType (PageParser pageParser)
{
string sourceFile = GenerateSourceFile (pageParser);
Console.WriteLine ("Compiling {0}", sourceFile);
return TemplateFactory.GetTypeFromSource (sourceFile);
}
private static string GenerateSourceFile (PageParser pageParser)
{
string inputFile = pageParser.InputFile;
Stream input = File.OpenRead (inputFile);
AspParser parser = new AspParser (inputFile, input);
parser.Parse ();
AspGenerator generator = new AspGenerator (inputFile, parser.Elements);
generator.BaseType = "System.Web.UI.Page";
generator.ProcessElements ();
pageParser.Text = generator.GetCode ().ReadToEnd ();
//FIXME: should get Tmp dir for this application
string csName = Path.GetTempFileName () + ".cs";
Console.WriteLine ("Writing {0}", csName);
StreamWriter output = new StreamWriter (File.OpenWrite (csName));
output.Write (pageParser.Text);
output.Close ();
return csName;
}
}
}