//
// Authors:
// Gonzalo Paniagua Javier (gonzalo@ximian.com)
+// Marek Habersack (mhabersack@novell.com)
//
-// (C) 2006 Novell, Inc (http://www.novell.com)
+// (C) 2006-2009 Novell, Inc (http://www.novell.com)
//
//
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-#if NET_2_0
using System;
using System.CodeDom;
using System.IO;
using System.Reflection;
using System.Web.UI;
+using System.Web.Util;
namespace System.Web.Compilation {
- sealed class PageBuildProvider : BuildProvider {
- PageCompiler pcompiler;
- CompilerType compiler_type;
-
+ [BuildProviderAppliesTo (BuildProviderAppliesTo.Web)]
+ sealed class PageBuildProvider : TemplateBuildProvider {
+
public PageBuildProvider()
{
}
- public override void GenerateCode (AssemblyBuilder assemblyBuilder)
+ protected override string MapPath (VirtualPath virtualPath)
{
- HttpContext context = HttpContext.Current;
- PageParser parser = new PageParser (VirtualPath, OpenReader (), context);
- pcompiler = new PageCompiler (parser);
- pcompiler.CreateMethods ();
- compiler_type = GetDefaultCompilerTypeForLanguage (parser.Language);
- using (TextWriter writer = assemblyBuilder.CreateCodeFile (this)) {
- CodeDomProvider provider = pcompiler.Provider;
- CodeCompileUnit unit = pcompiler.CompileUnit;
- provider.CreateGenerator().GenerateCodeFromCompileUnit (unit, writer, null);
- }
- }
+ // We need this hack to support out-of-application wsdl helpers
+ if (virtualPath.IsFake)
+ return virtualPath.PhysicalPath;
- public override Type GetGeneratedType (CompilerResults results)
+ return base.MapPath (virtualPath);
+ }
+
+ protected override TextReader SpecialOpenReader (VirtualPath virtualPath, out string physicalPath)
{
- // This is not called if compilation failed.
- // Returning null makes the caller throw an InvalidCastException
- Assembly assembly = results.CompiledAssembly;
- return assembly.GetType (pcompiler.Parser.ClassName);
+ // We need this hack to support out-of-application wsdl helpers
+ if (virtualPath.IsFake) {
+ physicalPath = virtualPath.PhysicalPath;
+ return new StreamReader (physicalPath);
+ } else
+ physicalPath = null;
+
+ return base.SpecialOpenReader (virtualPath, out physicalPath);
}
-
- public override CompilerType CodeCompilerType {
- get { return compiler_type; }
+
+ protected override BaseCompiler CreateCompiler (TemplateParser parser)
+ {
+ return new PageCompiler (parser as PageParser);
}
- // FIXME: figure this out.
- public override ICollection VirtualPathDependencies {
- get {
- return pcompiler.Parser.Dependencies;
- }
+ protected override TemplateParser CreateParser (VirtualPath virtualPath, string physicalPath, HttpContext context)
+ {
+ return CreateParser (virtualPath, physicalPath, OpenReader (virtualPath.Original), context);
+ }
+
+ protected override TemplateParser CreateParser (VirtualPath virtualPath, string physicalPath, TextReader reader, HttpContext context)
+ {
+ return new PageParser (virtualPath, physicalPath, reader, context);
}
}
}
-#endif
+