protected override void ConfigureHost(IMvcTextTemplateHost host, MvcFileName fileName)
		{
			var controllerFileName = fileName as MvcControllerFileName;
			host.ControllerName = controllerFileName.ControllerName;
			host.AddActionMethods = Template.AddActionMethods;
			host.Namespace = GetNamespace();
		}
		public void GenerateFile(MvcFileName fileName)
		{
			using (IMvcTextTemplateHostAppDomain appDomain = CreateAppDomain()) {
				using (IMvcTextTemplateHost host = CreateHost(appDomain)) {
					GenerateFile(host, fileName);
				}
			}
		} 
		void GenerateFile(IMvcTextTemplateHost host, MvcFileName fileName)
		{
			ConfigureHost(host, fileName);
			string templateFileName = GetTextTemplateFileName();
			string outputViewFileName = fileName.GetPath();
			host.ProcessTemplate(templateFileName, outputViewFileName);
			
			Errors = host.Errors;
			if (HasErrors) {
				errorReporter.ShowErrors(Errors);
			}
		}
		protected override void ConfigureHost(IMvcTextTemplateHost host, MvcFileName fileName)
		{
			host.IsContentPage = IsContentPage;
			host.MasterPageFile = MasterPageFile;
			host.PrimaryContentPlaceHolderID = PrimaryContentPlaceHolderId;
			host.ViewDataTypeName = ModelClassName;
			host.ViewDataTypeAssemblyLocation = ModelClassAssemblyLocation;
			
			var viewFileName = fileName as MvcViewFileName;
			host.IsPartialView = viewFileName.IsPartialView;
			host.ViewName = viewFileName.ViewName;
		}
Example #5
0
		void GenerateFile(IMvcTextTemplateHost host, MvcFileName fileName)
		{
			ConfigureHost(host, fileName);
			string templateFileName = GetTextTemplateFileName();
			string outputViewFileName = fileName.GetPath();
			host.ProcessTemplate(templateFileName, outputViewFileName);
			
			if (host.Errors.Count > 0) {
				CompilerError error = host.Errors[0];
				Console.WriteLine("ProcessTemplate error: " + error.ErrorText);
				Console.WriteLine("ProcessTemplate error: Line: " + error.Line);
			}
		}
		protected abstract void ConfigureHost(IMvcTextTemplateHost host, MvcFileName fileName);