mirror of
https://github.com/BepInEx/mono.git
synced 2026-11-17 19:10:23 -10:00
* 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
53 lines
1.3 KiB
C#
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;
|
|
}
|
|
}
|
|
}
|