Reverse previous changes
[mono.git] / mcs / class / System.Web / System.Web.Compilation / MasterPageBuildProvider.cs
index 455de2cfa316949582f8a58af5770bbbfac13de7..3be906f42b19b6edb00a86e9dde0acd56b1d7a43 100644 (file)
@@ -28,7 +28,6 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
-#if NET_2_0
 
 using System;
 using System.CodeDom;
@@ -42,49 +41,26 @@ using System.Web.UI;
 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
+