mirror of
https://github.com/BepInEx/mono.git
synced 2026-11-17 01:41:17 -10:00
* System.Web/HttpApplicationFactory.cs: add the context as parameter when building the application Type. * System.Web/HttpCookie.cs: new internal constructor. * System.Web/HttpCookieCollection.cs: new internal method to make a cookie expire. * System.Web/HttpRequest.cs: MapPath fixes. * System.Web/HttpResponse.cs: implemented ApplyAppPathModifier. * System.Web/HttpRuntime.cs: fixed typo in AppDomainAppVirtualPath. * System.Web.Compilation/AspGenerator.cs: now it uses the current HttpContext when creating user controls. TemplateSourceDirectory is no longer a dummy value. * System.Web.Compilation/GlobalAsaxCompiler.cs: * System.Web.Compilation/PageCompiler.cs: * System.Web.Compilation/UserControlCompiler.cs: set the context which will be used to locate the files. * System.Web.UI/BaseParser.cs: use MapPath and context to locate files. * System.Web.UI/Control.cs: implemented MapPathSecure. * System.Web.UI/TemplateControl.cs: use UrlUtils to generate the path. * System.Web.UI/TemplateControlParser.cs: use the context and MapPath. * System.Web.UI/UserControl.cs: implemented MapPath. * System.Web.UI/UserControlParser.cs: added context parameter to constructor. * System.Web.Util/PathUtil.cs: removed. * System.Web.Util/UrlUtils.cs: fixed Combine to handle '~'. svn path=/trunk/mcs/; revision=9737
105 lines
2.6 KiB
C#
105 lines
2.6 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.Reflection;
|
|
using System.Text;
|
|
using System.Web.UI;
|
|
using System.Web.Util;
|
|
|
|
namespace System.Web.Compilation
|
|
{
|
|
class PageCompiler : BaseCompiler
|
|
{
|
|
PageParser pageParser;
|
|
string sourceFile;
|
|
|
|
private PageCompiler (PageParser pageParser)
|
|
{
|
|
this.pageParser = pageParser;
|
|
}
|
|
|
|
public override Type GetCompiledType ()
|
|
{
|
|
string inputFile = pageParser.InputFile;
|
|
sourceFile = GenerateSourceFile ();
|
|
|
|
CachingCompiler compiler = new CachingCompiler (this);
|
|
CompilationResult result = new CompilationResult ();
|
|
result.Options = options;
|
|
if (compiler.Compile (result) == false)
|
|
throw new CompilationException (result);
|
|
|
|
Assembly assembly = Assembly.LoadFrom (result.OutputFile);
|
|
Type [] types = assembly.GetTypes ();
|
|
foreach (Type t in types) {
|
|
if (t.IsSubclassOf (typeof (Page))) {
|
|
if (result.Data != null)
|
|
throw new CompilationException ("More that 1 page!!!", result);
|
|
result.Data = t;
|
|
}
|
|
}
|
|
|
|
return result.Data as Type;
|
|
}
|
|
|
|
public override string Key {
|
|
get {
|
|
return pageParser.InputFile;
|
|
}
|
|
}
|
|
|
|
public override string SourceFile {
|
|
get {
|
|
return sourceFile;
|
|
}
|
|
}
|
|
|
|
public static Type CompilePageType (PageParser pageParser)
|
|
{
|
|
CompilationCacheItem item = CachingCompiler.GetCached (pageParser.InputFile);
|
|
if (item != null && item.Result != null) {
|
|
if (item.Result != null) {
|
|
pageParser.Options = item.Result.Options;
|
|
return item.Result.Data as Type;
|
|
}
|
|
|
|
throw new CompilationException (item.Result);
|
|
}
|
|
|
|
PageCompiler pc = new PageCompiler (pageParser);
|
|
return pc.GetCompiledType ();
|
|
}
|
|
|
|
string GenerateSourceFile ()
|
|
{
|
|
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.Context = pageParser.Context;
|
|
generator.BaseType = pageParser.BaseType.ToString ();
|
|
generator.ProcessElements ();
|
|
pageParser.Text = generator.GetCode ().ReadToEnd ();
|
|
options = generator.Options;
|
|
|
|
//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;
|
|
}
|
|
}
|
|
}
|
|
|