// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-#if NET_2_0
using System;
using System.CodeDom;
namespace System.Web.Compilation {
[BuildProviderAppliesTo (BuildProviderAppliesTo.Web)]
- sealed class MasterPageBuildProvider : BuildProvider {
- MasterPageCompiler pcompiler;
- CompilerType compiler_type;
-
+ sealed class MasterPageBuildProvider : TemplateBuildProvider {
public MasterPageBuildProvider()
{
}
- public override void GenerateCode (AssemblyBuilder assemblyBuilder)
- {
- HttpContext context = HttpContext.Current;
- MasterPageParser parser = new MasterPageParser (VirtualPath,
- VirtualPathUtility.ToAbsolute (VirtualPath),
- context);
- pcompiler = new MasterPageCompiler (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);
- }
- }
-
- public override Type GetGeneratedType (CompilerResults results)
+ protected override BaseCompiler CreateCompiler (TemplateParser parser)
{
- // 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);
+ return new MasterPageCompiler (parser as MasterPageParser);
}
- public override CompilerType CodeCompilerType {
- get { return compiler_type; }
+ protected override TemplateParser CreateParser (VirtualPath virtualPath, string physicalPath, HttpContext context)
+ {
+ return CreateParser (virtualPath, physicalPath, OpenReader (virtualPath.Original), context);
}
-
- // FIXME: figure this out.
- public override ICollection VirtualPathDependencies {
- get {
- return pcompiler.Parser.Dependencies;
- }
+
+ protected override TemplateParser CreateParser (VirtualPath virtualPath, string physicalPath, TextReader reader, HttpContext context)
+ {
+ return new MasterPageParser (virtualPath, physicalPath, reader, context);
}
}
}
-#endif
+