Beispiel #1
0
        public string Preview(TemplateInfo templateInfo, ITemplateGeneratorHost host, TemplateEngineSettings templateEngineSettings)
        {
            ValidationUtils.ArgumentNotNull(templateInfo, "templateInfo");
            ValidationUtils.ArgumentNotNull(host, "host");
            ValidationUtils.ArgumentNotNull(templateEngineSettings, "templateEngineSettings");

            log.Debug(string.Format("Running template {0} from {1}", templateInfo.Name, templateInfo.Directory));
            string result;

            try
            {
                _templateEngineSettings = templateEngineSettings;
                string relativePath = "";
                string templateFile = Path.Combine(templateInfo.Directory, "preview.template");

                TemplateContext templateContext = new TemplateContext(relativePath, templateInfo.Directory, host);
                PushContext(templateContext);
                result = InternalProcessTemplate(relativePath, templateFile, "preview", host);
                PopContext();
            }
            catch (Exception ex)
            {
                log.Error("Failed generating template preview", ex);
                throw ex;
            }
            //log.Debug(result);
            return(result);
        }
Beispiel #2
0
		public void Execute(TemplateInfo templateInfo, ITemplateGeneratorHost host, TemplateEngineSettings templateEngineSettings)
		{
			_templateEngineSettings = templateEngineSettings;
			string relativePath = "";
			try
			{
				host.Open();
				ProcessTemplates(relativePath, templateInfo.Directory, host);
			}
			finally
			{
				host.Close();
			}
		}
Beispiel #3
0
        public void Execute(TemplateInfo templateInfo, ITemplateGeneratorHost host, TemplateEngineSettings templateEngineSettings)
        {
            _templateEngineSettings = templateEngineSettings;
            string relativePath = "";

            try
            {
                host.Open();
                ProcessTemplates(relativePath, templateInfo.Directory, host);
            }
            finally
            {
                host.Close();
            }
        }
        public void Execute(TemplateInfo templateInfo, ITemplateGeneratorHost host, TemplateEngineSettings settings)
        {
            AppDomain temporaryDomain = CreateTempAppDomain();

            try
            {
                string baseDirectory      = temporaryDomain.BaseDirectory;
                string assembly           = Assembly.GetExecutingAssembly().GetName().FullName;
                string type               = this.GetType().FullName;
                TemplateEngineProxy proxy = (TemplateEngineProxy)temporaryDomain.CreateInstanceAndUnwrap(assembly, type);
                proxy._Execute(templateInfo, host, settings);
            }
            finally
            {
                AppDomain.Unload(temporaryDomain);
            }
        }
Beispiel #5
0
		public string Preview(TemplateInfo templateInfo, ITemplateGeneratorHost host, TemplateEngineSettings templateEngineSettings)
		{
			ValidationUtils.ArgumentNotNull(templateInfo, "templateInfo");
			ValidationUtils.ArgumentNotNull(host, "host");
			ValidationUtils.ArgumentNotNull(templateEngineSettings, "templateEngineSettings");

			log.Debug(string.Format("Running template {0} from {1}", templateInfo.Name, templateInfo.Directory));
			string result;
			try
			{
				_templateEngineSettings = templateEngineSettings;
				string relativePath = "";
				string templateFile = Path.Combine(templateInfo.Directory, "preview.template");

				TemplateContext templateContext = new TemplateContext(relativePath, templateInfo.Directory, host);
				PushContext(templateContext);
				result = InternalProcessTemplate(relativePath, templateFile, "preview",  host);
				PopContext();
			}
			catch(Exception ex)
			{
				log.Error("Failed generating template preview", ex);
				throw ex;
			}
			//log.Debug(result);
			return result;
		}
		public void Execute(TemplateInfo templateInfo, ITemplateGeneratorHost host, TemplateEngineSettings settings)
		{
			AppDomain temporaryDomain = CreateTempAppDomain();
			try
			{
				string baseDirectory = temporaryDomain.BaseDirectory;
				string assembly = Assembly.GetExecutingAssembly().GetName().FullName;
				string type = this.GetType().FullName;
				TemplateEngineProxy proxy = (TemplateEngineProxy)temporaryDomain.CreateInstanceAndUnwrap(assembly, type);
				proxy._Execute(templateInfo, host, settings);
			}
			finally
			{
				AppDomain.Unload(temporaryDomain);
			}
		}
		internal string _Preview(TemplateInfo templateInfo, ITemplateGeneratorHost host, TemplateEngineSettings settings)
		{
			StartLogging();
			ILog log = LogManager.GetLogger(typeof(TemplateEngineProxy));
			log.Debug(string.Format("Entering AppDomain: {0} {1}", AppDomain.CurrentDomain.FriendlyName, AppDomain.CurrentDomain.BaseDirectory));
			TemplateEngine templateEngine = new TemplateEngine();
			ValidationUtils.ObjectNotNull(templateEngine, "templateEngine");
			return templateEngine.Preview(templateInfo, host, settings);
		}
		public string Preview(TemplateInfo templateInfo, ITemplateGeneratorHost host, TemplateEngineSettings settings)
		{
			AppDomain temporaryDomain = CreateTempAppDomain();
			try
			{
				string assembly = Assembly.GetExecutingAssembly().GetName().FullName;
				string type = this.GetType().FullName;
				log.Debug(string.Format("CreateInstanceAndUnwrap {0} {1}", assembly, type));
				TemplateEngineProxy proxy = (TemplateEngineProxy)temporaryDomain.CreateInstanceAndUnwrap(assembly, type);
				if( proxy == null )
				{
					string msg = string.Format("Failed to locate the requested  type {0}", type);
					log.Debug(msg);
					throw new ServiceBrowserException(msg);
				}
				else
				{
					string result = proxy._Preview(templateInfo, host, settings);
					//log.Debug(result);
					return result;
				}
			}
			finally
			{
				AppDomain.Unload(temporaryDomain);
			}
		}
		internal void _Execute(TemplateInfo templateInfo, ITemplateGeneratorHost host, TemplateEngineSettings settings)
		{
			StartLogging();
			ILog log = LogManager.GetLogger(typeof(TemplateEngineProxy));
			log.Debug(string.Format("Entering AppDomain: {0} {1}", AppDomain.CurrentDomain.FriendlyName, AppDomain.CurrentDomain.BaseDirectory));
			TemplateEngine templateEngine = new TemplateEngine();
			templateEngine.Execute(templateInfo, host, settings);
		}
        internal string _Preview(TemplateInfo templateInfo, ITemplateGeneratorHost host, TemplateEngineSettings settings)
        {
            StartLogging();
            ILog log = LogManager.GetLogger(typeof(TemplateEngineProxy));

            log.Debug(string.Format("Entering AppDomain: {0} {1}", AppDomain.CurrentDomain.FriendlyName, AppDomain.CurrentDomain.BaseDirectory));
            TemplateEngine templateEngine = new TemplateEngine();

            ValidationUtils.ObjectNotNull(templateEngine, "templateEngine");
            return(templateEngine.Preview(templateInfo, host, settings));
        }
        public string Preview(TemplateInfo templateInfo, ITemplateGeneratorHost host, TemplateEngineSettings settings)
        {
            AppDomain temporaryDomain = CreateTempAppDomain();

            try
            {
                string assembly = Assembly.GetExecutingAssembly().GetName().FullName;
                string type     = this.GetType().FullName;
                log.Debug(string.Format("CreateInstanceAndUnwrap {0} {1}", assembly, type));
                TemplateEngineProxy proxy = (TemplateEngineProxy)temporaryDomain.CreateInstanceAndUnwrap(assembly, type);
                if (proxy == null)
                {
                    string msg = string.Format("Failed to locate the requested  type {0}", type);
                    log.Debug(msg);
                    throw new ServiceBrowserException(msg);
                }
                else
                {
                    string result = proxy._Preview(templateInfo, host, settings);
                    //log.Debug(result);
                    return(result);
                }
            }
            finally
            {
                AppDomain.Unload(temporaryDomain);
            }
        }
        internal void _Execute(TemplateInfo templateInfo, ITemplateGeneratorHost host, TemplateEngineSettings settings)
        {
            StartLogging();
            ILog log = LogManager.GetLogger(typeof(TemplateEngineProxy));

            log.Debug(string.Format("Entering AppDomain: {0} {1}", AppDomain.CurrentDomain.FriendlyName, AppDomain.CurrentDomain.BaseDirectory));
            TemplateEngine templateEngine = new TemplateEngine();

            templateEngine.Execute(templateInfo, host, settings);
        }