Files
mono/mcs/class/System.Web/System.Web.Compilation/PageCompiler.cs
T
Gonzalo Paniagua Javier 095823b134 2002-10-27 Gonzalo Paniagua Javier <[email protected]>
* list: added WebEncoding.cs

	* System.Web/HttpApplication.cs: reenabled a few lines of code
	(ThreadPool already fixed).

	* System.Web/HttpRequest.cs:
	* System.Web/HttpResponse.cs:
	* System.Web/HttpUtility.cs:
	* System.Web/HttpValueCollection.cs:
	* System.Web/HttpWriter.cs:
	* System.Web.UI/LosFormatter.cs:
	Use WebEncoding.Encoding.

	* System.Web.Compilation/PageCompiler.cs: tracing.
	* System.Web.Compilation/TemplateFactory.cs: cache compiled types and
	tracing.
	* System.Web.Compilation/WebServiceCompiler.cs: new parameter in
	GetTypeFromsource,
	* System.Web.Configuration/HttpHandlersSectionHandler.cs: more null
	checks.

	* System.Web.UI/Control.cs:
	* System.Web.UI/Page.cs:
	* System.Web.Util/WebTrace.cs: fixed namespace.

	* System.Web.Util/WebEncoding.cs: new class that holds the default
	encoding for System.Web.

svn path=/trunk/mcs/; revision=8599
2002-10-27 19:55:28 +00:00

54 lines
1.4 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;
using System.Web.Util;
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);
WebTrace.WriteLine ("Compiling {0} ({1})", sourceFile, pageParser.InputFile);
return TemplateFactory.GetTypeFromSource (pageParser.InputFile, 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";
WebTrace.WriteLine ("Writing {0}", csName);
StreamWriter output = new StreamWriter (File.OpenWrite (csName));
output.Write (pageParser.Text);
output.Close ();
return csName;
}
}
}