// 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 UserControlBuildProvider : BuildProvider {
- UserControlCompiler uccompiler;
- CompilerType compiler_type;
-
+ sealed class UserControlBuildProvider : TemplateBuildProvider {
public UserControlBuildProvider ()
{
}
- public override void GenerateCode (AssemblyBuilder assemblyBuilder)
- {
- HttpContext context = HttpContext.Current;
- UserControlParser parser = new UserControlParser (VirtualPath, OpenReader (), context);
- uccompiler = new UserControlCompiler (parser);
- uccompiler.CreateMethods ();
- compiler_type = GetDefaultCompilerTypeForLanguage (parser.Language);
- using (TextWriter writer = assemblyBuilder.CreateCodeFile (this)) {
- CodeDomProvider provider = uccompiler.Provider;
- CodeCompileUnit unit = uccompiler.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 (uccompiler.Parser.ClassName);
+ return new UserControlCompiler (parser as UserControlParser);
}
- 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 uccompiler.Parser.Dependencies;
- }
+
+ protected override TemplateParser CreateParser (VirtualPath virtualPath, string physicalPath, TextReader reader, HttpContext context)
+ {
+ return new UserControlParser (virtualPath, physicalPath, reader, context);
}
}
}
-#endif
+