/// <summary> /// Generates template based select field based on reflected modeled table field attributes with values derived from ValueList table. /// </summary> /// <typeparam name="T">Modeled table for select field.</typeparam> /// <param name="groupName">Value list group name as defined in ValueListGroup table.</param> /// <param name="fieldName">Field name for value of select field.</param> /// <param name="fieldLabel">Label name for select field, pulls from <see cref="LabelAttribute"/> if defined, otherwise defaults to <paramref name="fieldName"/>.</param> /// <param name="fieldID">ID to use for select field; defaults to select + <paramref name="fieldName"/>.</param> /// <param name="groupDataBinding">Data-bind operations to apply to outer form-group div, if any.</param> /// <param name="labelDataBinding">Data-bind operations to apply to label, if any.</param> /// <param name="customDataBinding">Extra custom data-binding operations to apply to field, if any.</param> /// <param name="dependencyFieldName">Defines default "enabled" subordinate data-bindings based a single boolean field, e.g., a check-box.</param> /// <param name="optionDataBinding">Data-bind operations to apply to each option value, if any.</param> /// <param name="toolTip">Tool tip text to apply to field, if any.</param> /// <returns>Generated HTML for new text field based on modeled table field attributes.</returns> public static string AddDirectoryBrowser(string fieldName, bool required, int maxLength = 0, string inputType = null, string fieldLabel = null, string fieldID = null, string groupDataBinding = null, string labelDataBinding = null, string requiredDataBinding = null, string customDataBinding = null, string dependencyFieldName = null, string toolTip = null) { IRazorEngine m_razorEngine = RazorEngine <CSharpEmbeddedResource> .Default; RazorView addInputFieldTemplate = new RazorView(m_razorEngine, $"DirectoryBrowser.cshtml", null); DynamicViewBag viewBag = addInputFieldTemplate.ViewBag; if (string.IsNullOrEmpty(fieldID)) { fieldID = $"input{fieldName}"; } viewBag.AddValue("FieldName", fieldName); viewBag.AddValue("Required", required); viewBag.AddValue("MaxLength", maxLength); viewBag.AddValue("InputType", inputType ?? "text"); viewBag.AddValue("FieldLabel", fieldLabel ?? fieldName); viewBag.AddValue("FieldID", fieldID); viewBag.AddValue("GroupDataBinding", groupDataBinding); viewBag.AddValue("LabelDataBinding", labelDataBinding); viewBag.AddValue("RequiredDataBinding", requiredDataBinding); viewBag.AddValue("CustomDataBinding", customDataBinding); viewBag.AddValue("DependencyFieldName", dependencyFieldName); viewBag.AddValue("ToolTip", toolTip); return(addInputFieldTemplate.Execute()); }
// Static Methods /// <summary> /// Gets a shared <see cref="WebServer"/> instance created based on configured options defined in the specified <paramref name="settingsCategory"/>. /// </summary> /// <param name="settingsCategory">Settings category to use for web server options; defaults to "systemSettings".</param> /// <param name="razorEngineCS">Razor engine instance for .cshtml templates; uses default instance if not provided.</param> /// <param name="razorEngineVB">Razor engine instance for .vbhtml templates; uses default instance if not provided.</param> /// <returns>Shared <see cref="WebServer"/> instance created based on configured options.</returns> public static WebServer GetConfiguredServer(string settingsCategory = null, IRazorEngine razorEngineCS = null, IRazorEngine razorEngineVB = null) { lock (typeof(WebServer)) { if (string.IsNullOrWhiteSpace(settingsCategory)) { settingsCategory = "systemSettings"; } return(s_configuredServers.GetOrAdd(settingsCategory, category => { // Get configured template path CategorizedSettingsElementCollection settings = ConfigurationFile.Current.Settings[category]; settings.Add("WebRootPath", "wwwroot", "The root path for the hosted web server files. Location will be relative to install folder if full path is not specified."); settings.Add("ClientCacheEnabled", "true", "Determines if cache control is enabled for web server when rendering content to browser clients."); settings.Add("MinifyJavascript", "true", "Determines if minification should be applied to rendered Javascript files."); settings.Add("MinifyStyleSheets", "true", "Determines if minification should be applied to rendered CSS files."); settings.Add("UseMinifyInDebug", "false", "Determines if minification should be applied when running a Debug build."); return new WebServer(FilePath.GetAbsolutePath(settings["WebRootPath"].Value), razorEngineCS, razorEngineVB) { ClientCacheEnabled = settings["ClientCacheEnabled"].Value.ParseBoolean(), MinifyJavascript = settings["MinifyJavascript"].Value.ParseBoolean(), MinifyStyleSheets = settings["MinifyStyleSheets"].Value.ParseBoolean(), UseMinifyInDebug = settings["UseMinifyInDebug"].Value.ParseBoolean() }; })); } }
public CommandFactory(ILog log, IRepositoriesFactory dalRepositories, DBMS.Contracts.IRepositoriesFactory dbmsRepositories, IRazorEngine razorEngine) { this.log = log; this.dalRepositories = dalRepositories; this.dbmsRepositories = dbmsRepositories; this.razorEngine = razorEngine; }
private void initDefault() { if (defaultTemplate != null) { return; } lock (this) { if (defaultTemplate == null) { defaultTemplate = new CSharpTemplate(); } else { return; } razorEngine = new RazorEngine(); beanTemplate = GetTemplate <CSharpClass>(javaBeanTemplateRelatePath); daoTemplate = GetTemplate <JavaDaoConfig>(javaDaoTemplateRelatePath); mapperTemplate = GetTemplate <JavaMapperConfig>(javaMapperTemplateRelatePath); codeTemplate = GetTemplate <JavaCodeConfig>(javaCodeTemplateRelatePath); defaultTemplate.beanTemplate = beanTemplate; defaultTemplate.daoTemplate = daoTemplate; defaultTemplate.mapperTemplate = mapperTemplate; defaultTemplate.serviceTemplate = codeTemplate; defaultTemplate.modelTemplate = codeTemplate; defaultTemplate.serviceImplTemplate = codeTemplate; defaultTemplate.controllerTemplate = codeTemplate; } }
/// <summary> /// Creates a new <see cref="WebServer"/>. /// </summary> /// <param name="options">Web server options to use; set to <c>null</c> for defaults.</param> /// <param name="razorEngineCS">Razor engine instance for .cshtml templates; uses default instance if not provided.</param> /// <param name="razorEngineVB">Razor engine instance for .vbhtml templates; uses default instance if not provided.</param> public WebServer(WebServerOptions options = null, IRazorEngine razorEngineCS = null, IRazorEngine razorEngineVB = null) { m_releaseMode = !AssemblyInfo.EntryAssembly.Debuggable; if ((object)options == null) { options = new WebServerOptions(); } m_options = options; RazorEngineCS = razorEngineCS ?? (m_releaseMode ? RazorEngine <CSharp> .Default : RazorEngine <CSharpDebug> .Default as IRazorEngine); RazorEngineVB = razorEngineVB ?? (m_releaseMode ? RazorEngine <VisualBasic> .Default : RazorEngine <VisualBasicDebug> .Default as IRazorEngine); PagedViewModelTypes = new ConcurrentDictionary <string, Tuple <Type, Type> >(StringComparer.InvariantCultureIgnoreCase); m_etagCache = new ConcurrentDictionary <string, long>(StringComparer.InvariantCultureIgnoreCase); m_handlerTypeCache = new ConcurrentDictionary <string, Type>(StringComparer.InvariantCultureIgnoreCase); // Validate web root path m_options.WebRootPath = FilePath.AddPathSuffix(m_options.WebRootPath ?? RazorEngineCS.TemplatePath); m_fileWatcher = new SafeFileWatcher(m_options.WebRootPath) { IncludeSubdirectories = true, EnableRaisingEvents = true }; m_fileWatcher.Changed += m_fileWatcher_FileChange; m_fileWatcher.Deleted += m_fileWatcher_FileChange; m_fileWatcher.Renamed += m_fileWatcher_FileChange; }
static RazorUtil() { var builder = new RazorEngineBuilder().UseToolkitProject().UseBaseType(BASE_TYPE); ToolkitEngine = builder.Build(); builder = new RazorEngineBuilder().UseToolkitProject().UseBaseType(BASE_LIST_TYPE); ListEngine = builder.Build(); builder = new RazorEngineBuilder().UseToolkitProject().UseBaseType(BASE_MULTI_EDIT_TYPE); MultiEditEngine = builder.Build(); TextEngine = new RazorEngineBuilder().Build(); }
/// <summary> /// Creates a new <see cref="RazorView"/>. /// </summary> /// <param name="razorEngine"><see cref="IRazorEngine"/> instance to use.</param> /// <param name="templateName">Name of template file, typically a .cshtml or .vbhtml file.</param> /// <param name="model">Reference to model to use when rendering template.</param> /// <param name="modelType">Type of <paramref name="model"/>.</param> /// <param name="pagedViewModelDataType">Type of data class for views based on paged view model, if any.</param> /// <param name="pagedViewModelHubType">Type of SignalR hub for views based on paged view model, if any.</param> /// <param name="database"><see cref="AdoDataConnection"/> to use, if any.</param> /// <param name="exceptionHandler">Delegate to handle exceptions, if any.</param> public RazorView(IRazorEngine razorEngine, string templateName, object model = null, Type modelType = null, Type pagedViewModelDataType = null, Type pagedViewModelHubType = null, AdoDataConnection database = null, Action<Exception> exceptionHandler = null) { m_razorEngine = razorEngine; TemplateName = templateName; Model = model; ModelType = modelType; PagedViewModelDataType = pagedViewModelDataType; PagedViewModelHubType = pagedViewModelHubType; Database = database; ExceptionHandler = exceptionHandler; }
/// <summary> /// Creates a new <see cref="RazorView"/>. /// </summary> /// <param name="razorEngine"><see cref="IRazorEngine"/> instance to use.</param> /// <param name="templateName">Name of template file, typically a .cshtml or .vbhtml file.</param> /// <param name="model">Reference to model to use when rendering template.</param> /// <param name="modelType">Type of <paramref name="model"/>.</param> /// <param name="pagedViewModelDataType">Type of data class for views based on paged view model, if any.</param> /// <param name="pagedViewModelHubType">Type of SignalR hub for views based on paged view model, if any.</param> /// <param name="database"><see cref="AdoDataConnection"/> to use, if any.</param> /// <param name="exceptionHandler">Delegate to handle exceptions, if any.</param> public RazorView(IRazorEngine razorEngine, string templateName, object model = null, Type modelType = null, Type pagedViewModelDataType = null, Type pagedViewModelHubType = null, AdoDataConnection database = null, Action <Exception> exceptionHandler = null) { m_razorEngine = razorEngine; TemplateName = templateName; Model = model; ModelType = modelType; PagedViewModelDataType = pagedViewModelDataType; PagedViewModelHubType = pagedViewModelHubType; Database = database; ExceptionHandler = exceptionHandler; }
private string RazorOutputFile(object tableData, object model, object pageData, string RazorFile, bool isEdit, int?index = null) { var viewBag = GetNewViewBag(tableData, pageData, CreateCustomData(isEdit), index); IRazorEngine engine = RazorEnginePlugInFactory.CreateRazorEngine(RazorUtil.MULTIEDIT_ENGINE_NAME); string content = Task.Run(async() => await RazorExtension.CompileRenderWithLayoutAsync(engine, RazorFile, null, model, null, viewBag)).GetAwaiter().GetResult(); return(content); }
public Task Process(HttpContext context) { dynamic model = new ExpandoObject(); string fileName = GetFileName(); IRazorEngine razorEngine = RazorUtil.ToolkitEngine; string html = Task.Run(async() => await RazorExtension.CompileRenderWithLayoutAsync(razorEngine, fileName, null, model, null)).GetAwaiter().GetResult(); return(context.Response.WriteAsync(html)); }
public PresentationService( IRepository<Batch> batches, IRepository<Template> templates, ILatexEngine latexEngine, IRazorEngine razorEngine, IFileStore fileStore) { _batches = batches; _templates = templates; _latexEngine = latexEngine; _razorEngine = razorEngine; _fileStore = fileStore; }
private static string Execute(object model, dynamic viewBag, PageTemplateInitData initData, string razorFile, string layout, IPageTemplate pageTemplate, ISource source, IInputData input, OutputData outputData) { string engineName = pageTemplate.GetEngineName(source, input, outputData); IRazorEngine engine = RazorEnginePlugInFactory.CreateRazorEngine(engineName); string content = Task.Run(async() => await RazorExtension.CompileRenderWithLayoutAsync(engine, razorFile, layout, model, initData, viewBag)).GetAwaiter().GetResult(); return(content); }
public IContent WritePage(ISource source, IPageData pageData, OutputData outputData) { object model = WebRazorUtil.GetModel(outputData); var viewBag = WebRazorUtil.GetViewBag(pageData, fMetaData, null, RazorData); IRazorEngine engine = RazorEnginePlugInFactory.CreateRazorEngine(EngineName); string fileName = UseTemplate ? WebRazorUtil.GetTemplateFile(fFileName) : fFileName; string content = Task.Run(async() => await RazorExtension.CompileRenderWithLayoutAsync(engine, fileName, Layout, model, null, viewBag)).GetAwaiter().GetResult(); return(new SimpleContent(ContentTypeConst.HTML, content)); }
public static IRazorEngine CreateRazorEngine(string engineName) { if (string.IsNullOrEmpty(engineName)) { return(RazorUtil.ToolkitEngine); } TkDebug.ThrowIfNoGlobalVariable(); RazorEnginePlugInFactory factory = BaseGlobalVariable.Current.FactoryManager .GetCodeFactory(REG_NAME).Convert <RazorEnginePlugInFactory>(); IRazorEngine engine = factory.CreateInstance <IRazorEngine>(engineName); return(engine); }
public static WebServer GetConfiguredServer(string settingsCategory = null, IRazorEngine razorEngineCS = null, IRazorEngine razorEngineVB = null) { lock (typeof(WebServer)) { if (string.IsNullOrWhiteSpace(settingsCategory)) { settingsCategory = "systemSettings"; } return(s_configuredServers.GetOrAdd(settingsCategory, category => { // Get configured web server settings CategorizedSettingsElementCollection settings = ConfigurationFile.Current.Settings[category]; settings.Add(nameof(WebServerOptions.WebRootPath), WebServerOptions.DefaultWebRootPath, "The root path for the hosted web server files. Location will be relative to install folder if full path is not specified."); settings.Add(nameof(WebServerOptions.ClientCacheEnabled), WebServerOptions.DefaultClientCacheEnabled, "Determines if cache control is enabled for web server when rendering content to browser clients."); settings.Add(nameof(WebServerOptions.MinifyJavascript), WebServerOptions.DefaultMinifyJavascript, "Determines if minification should be applied to rendered Javascript files."); settings.Add(nameof(WebServerOptions.MinifyJavascriptExclusionExpression), WebServerOptions.DefaultMinifyJavascriptExclusionExpression, "Defines the regular expression that will exclude Javascript files from being minified. Empty value will target all files for minification."); settings.Add(nameof(WebServerOptions.MinifyStyleSheets), WebServerOptions.DefaultMinifyStyleSheets, "Determines if minification should be applied to rendered CSS files."); settings.Add(nameof(WebServerOptions.MinifyStyleSheetsExclusionExpression), WebServerOptions.DefaultMinifyStyleSheetsExclusionExpression, "Defines the regular expression that will exclude CSS files from being minified. Empty value will target all files for minification."); settings.Add(nameof(WebServerOptions.UseMinifyInDebug), WebServerOptions.DefaultUseMinifyInDebug, "Determines if minification should be applied when running a Debug build."); settings.Add(nameof(SessionHandler.SessionToken), SessionHandler.DefaultSessionToken, "Defines the token used for identifying the session ID in cookie headers."); settings.Add(nameof(AuthenticationOptions.AuthTestPage), AuthenticationOptions.DefaultAuthTestPage, "Defines the page name for the web server to test if a user is authenticated."); settings.Add(nameof(WebServerOptions.ErrorTemplateName), WebServerOptions.DefaultErrorTemplateName, "Defines the template file name to use when a Razor compile or execution exception occurs. Leave blank for none."); WebServerOptions options = new WebServerOptions { WebRootPath = settings[nameof(WebServerOptions.WebRootPath)].ValueAs(WebServerOptions.DefaultWebRootPath), ClientCacheEnabled = settings[nameof(WebServerOptions.ClientCacheEnabled)].ValueAsBoolean(WebServerOptions.DefaultClientCacheEnabled), MinifyJavascript = settings[nameof(WebServerOptions.MinifyJavascript)].ValueAsBoolean(WebServerOptions.DefaultMinifyJavascript), MinifyJavascriptExclusionExpression = settings[nameof(WebServerOptions.MinifyJavascriptExclusionExpression)].ValueAs(WebServerOptions.DefaultMinifyJavascriptExclusionExpression), MinifyStyleSheets = settings[nameof(WebServerOptions.MinifyStyleSheets)].ValueAsBoolean(WebServerOptions.DefaultMinifyStyleSheets), MinifyStyleSheetsExclusionExpression = settings[nameof(WebServerOptions.MinifyStyleSheetsExclusionExpression)].ValueAs(WebServerOptions.DefaultMinifyStyleSheetsExclusionExpression), UseMinifyInDebug = settings[nameof(WebServerOptions.UseMinifyInDebug)].ValueAsBoolean(WebServerOptions.DefaultUseMinifyInDebug), SessionToken = settings[nameof(SessionHandler.SessionToken)].ValueAs(SessionHandler.DefaultSessionToken), AuthTestPage = settings[nameof(AuthenticationOptions.AuthTestPage)].ValueAs(AuthenticationOptions.DefaultAuthTestPage), ErrorTemplateName = settings[nameof(WebServerOptions.ErrorTemplateName)].ValueAs(WebServerOptions.DefaultErrorTemplateName) }; return new WebServer(options, razorEngineCS, razorEngineVB); })); } }
private IRazorEngineCompiledTemplate <RazorEngineTemplateBase <T> > GetTemplate <T>(string filepath) { razorEngine = new RazorEngine(); string templatePath = Environment.CurrentDirectory + filepath; string templateContent = File.ReadAllText(templatePath); IRazorEngineCompiledTemplate <RazorEngineTemplateBase <T> > razorTemplate = razorEngine.Compile <RazorEngineTemplateBase <T> >(templateContent, builder => { //builder.AddAssemblyReferenceByName("System.Security"); // by name //builder.AddAssemblyReference(typeof(System.IO.File)); // by type //builder.AddAssemblyReference(Assembly.Load("source")); // by reference builder.AddAssemblyReferenceByName("System.Collections"); builder.AddAssemblyReference(typeof(CodeUtil)); // by type builder.AddAssemblyReference(typeof(ReverseStrTagHelper)); // by type }); return(razorTemplate); }
/// <summary> /// Creates a new <see cref="WebServer"/>. /// </summary> /// <param name="webRootPath">Root path for web server; defaults to template path for <paramref name="razorEngineCS"/>.</param> /// <param name="razorEngineCS">Razor engine instance for .cshtml templates; uses default instance if not provided.</param> /// <param name="razorEngineVB">Razor engine instance for .vbhtml templates; uses default instance if not provided.</param> public WebServer(string webRootPath = null, IRazorEngine razorEngineCS = null, IRazorEngine razorEngineVB = null) { bool releaseMode = !AssemblyInfo.EntryAssembly.Debuggable; m_razorEngineCS = razorEngineCS ?? (releaseMode ? RazorEngine <CSharp> .Default : RazorEngine <CSharpDebug> .Default as IRazorEngine); m_razorEngineVB = razorEngineVB ?? (releaseMode ? RazorEngine <VisualBasic> .Default : RazorEngine <VisualBasicDebug> .Default as IRazorEngine); m_webRootPath = FilePath.AddPathSuffix(webRootPath ?? m_razorEngineCS.TemplatePath); m_etagCache = new ConcurrentDictionary <string, uint>(StringComparer.InvariantCultureIgnoreCase); m_pagedViewModelTypes = new ConcurrentDictionary <string, Tuple <Type, Type> >(StringComparer.InvariantCultureIgnoreCase); m_fileWatcher = new SafeFileWatcher(m_webRootPath) { IncludeSubdirectories = true, EnableRaisingEvents = true }; m_fileWatcher.Changed += m_fileWatcher_FileChange; m_fileWatcher.Deleted += m_fileWatcher_FileChange; m_fileWatcher.Renamed += m_fileWatcher_FileChange; ClientCacheEnabled = true; }
public static async Task <string> CompileRenderWithLayoutAsync <T>(this IRazorEngine engine, string key, string layout, T model, object initData, ExpandoObject viewBag = null) { TkDebug.AssertArgumentNull(engine, nameof(engine), null); var handler = engine.Handler; ITemplatePage page; if (string.IsNullOrEmpty(key)) { page = await handler.CompileTemplateAsync(layout); } else { page = await handler.CompileTemplateAsync(key); page.Layout = layout; } page.RazorEngine = engine; return(await handler.RenderTemplateAsync(page, model, initData, viewBag)); }
public static WebServer GetConfiguredServer(string settingsCategory = null, IRazorEngine razorEngineCS = null, IRazorEngine razorEngineVB = null) { lock (typeof(WebServer)) { if (string.IsNullOrWhiteSpace(settingsCategory)) { settingsCategory = "systemSettings"; } return(s_configuredServers.GetOrAdd(settingsCategory, category => { // Get configured web server settings CategorizedSettingsElementCollection settings = ConfigurationFile.Current.Settings[category]; settings.Add("WebRootPath", WebServerOptions.DefaultWebRootPath, "The root path for the hosted web server files. Location will be relative to install folder if full path is not specified."); settings.Add("ClientCacheEnabled", WebServerOptions.DefaultClientCacheEnabled, "Determines if cache control is enabled for web server when rendering content to browser clients."); settings.Add("MinifyJavascript", WebServerOptions.DefaultMinifyJavascript, "Determines if minification should be applied to rendered Javascript files."); settings.Add("MinifyStyleSheets", WebServerOptions.DefaultMinifyStyleSheets, "Determines if minification should be applied to rendered CSS files."); settings.Add("UseMinifyInDebug", WebServerOptions.DefaultUseMinifyInDebug, "Determines if minification should be applied when running a Debug build."); settings.Add("SessionToken", SessionHandler.DefaultSessionToken, "Defines the token used for identifying the session ID in cookie headers."); settings.Add("AuthTestPage", AuthenticationOptions.DefaultAuthTestPage, "Defines the page name for the web server to test if a user is authenticated."); WebServerOptions options = new WebServerOptions { WebRootPath = settings["WebRootPath"].ValueAs(WebServerOptions.DefaultWebRootPath), ClientCacheEnabled = settings["ClientCacheEnabled"].ValueAsBoolean(WebServerOptions.DefaultClientCacheEnabled), MinifyJavascript = settings["MinifyJavascript"].ValueAsBoolean(WebServerOptions.DefaultMinifyJavascript), MinifyStyleSheets = settings["MinifyStyleSheets"].ValueAsBoolean(WebServerOptions.DefaultMinifyStyleSheets), UseMinifyInDebug = settings["UseMinifyInDebug"].ValueAsBoolean(WebServerOptions.DefaultUseMinifyInDebug), SessionToken = settings["SessionToken"].ValueAs(SessionHandler.DefaultSessionToken), AuthTestPage = settings["AuthTestPage"].ValueAs(AuthenticationOptions.DefaultAuthTestPage) }; return new WebServer(options, razorEngineCS, razorEngineVB); })); } }
public Index(IRazorEngine razorEngine, IDailyHeilContextFactory contextFactory) { _razorEngine = razorEngine; _contextFactory = contextFactory; }
public static void Initialize() { engine = new RazorEngine(); }
/// <summary> /// Creates a new <see cref="RazorView"/>. /// </summary> /// <param name="razorEngine"><see cref="IRazorEngine"/> instance to use.</param> /// <param name="templateName">Name of template file, typically a .cshtml or .vbhtml file.</param> /// <param name="exceptionHandler">Delegate to handle exceptions, if any.</param> public RazorView(IRazorEngine razorEngine, string templateName, Action<Exception> exceptionHandler = null) : this(razorEngine, templateName, null, null, null, null, null, exceptionHandler) { }
/// <summary> /// Creates a new <see cref="RazorView"/>. /// </summary> /// <param name="razorEngine"><see cref="IRazorEngine"/> instance to use.</param> /// <param name="templateName">Name of template file, typically a .cshtml or .vbhtml file.</param> /// <param name="exceptionHandler">Delegate to handle exceptions, if any.</param> public RazorView(IRazorEngine razorEngine, string templateName, Action <Exception> exceptionHandler = null) : this(razorEngine, templateName, null, null, null, null, null, exceptionHandler) { }
public History(IDailyHeilContextFactory contextFactory, IRazorEngine razorEngine) { _contextFactory = contextFactory; _razorEngine = razorEngine; }
public GenerateEmailCommand(ReportContextWithModel <TModel> context, ISettingPropertiesRepository settingPropertiesRepository, IRazorEngine razorEngine) { this.context = context; this.settingPropertiesRepository = settingPropertiesRepository; this.razorEngine = razorEngine; }
/// <summary> /// Creates a new <see cref="WebServer"/>. /// </summary> /// <param name="webRootPath">Root path for web server; defaults to template path for <paramref name="razorEngineCS"/>.</param> /// <param name="razorEngineCS">Razor engine instance for .cshtml templates; uses default instance if not provided.</param> /// <param name="razorEngineVB">Razor engine instance for .vbhtml templates; uses default instance if not provided.</param> public WebServer(string webRootPath = null, IRazorEngine razorEngineCS = null, IRazorEngine razorEngineVB = null) { m_releaseMode = !AssemblyInfo.EntryAssembly.Debuggable; m_razorEngineCS = razorEngineCS ?? (m_releaseMode ? RazorEngine<CSharp>.Default : RazorEngine<CSharpDebug>.Default as IRazorEngine); m_razorEngineVB = razorEngineVB ?? (m_releaseMode ? RazorEngine<VisualBasic>.Default : RazorEngine<VisualBasicDebug>.Default as IRazorEngine); m_webRootPath = FilePath.AddPathSuffix(webRootPath ?? m_razorEngineCS.TemplatePath); m_etagCache = new ConcurrentDictionary<string, long>(StringComparer.InvariantCultureIgnoreCase); m_handlerTypeCache = new ConcurrentDictionary<string, Type>(StringComparer.InvariantCultureIgnoreCase); m_pagedViewModelTypes = new ConcurrentDictionary<string, Tuple<Type, Type>>(StringComparer.InvariantCultureIgnoreCase); m_fileWatcher = new SafeFileWatcher(m_webRootPath) { IncludeSubdirectories = true, EnableRaisingEvents = true }; m_fileWatcher.Changed += m_fileWatcher_FileChange; m_fileWatcher.Deleted += m_fileWatcher_FileChange; m_fileWatcher.Renamed += m_fileWatcher_FileChange; ClientCacheEnabled = true; }
public Faq(IRazorEngine razorEngine) { _razorEngine = razorEngine; }
public MailTemplateManager(IRazorEngine razorEngine) { _razorEngine = razorEngine; _templates = InitializeTemplates(); }
public static WebServer GetConfiguredServer(string settingsCategory = null, IRazorEngine razorEngineCS = null, IRazorEngine razorEngineVB = null) { lock (typeof(WebServer)) { if (string.IsNullOrWhiteSpace(settingsCategory)) settingsCategory = "systemSettings"; return s_configuredServers.GetOrAdd(settingsCategory, category => { // Get configured template path CategorizedSettingsElementCollection settings = ConfigurationFile.Current.Settings[category]; settings.Add("WebRootPath", "wwwroot", "The root path for the hosted web server files. Location will be relative to install folder if full path is not specified."); settings.Add("ClientCacheEnabled", "true", "Determines if cache control is enabled for web server when rendering content to browser clients."); settings.Add("MinifyJavascript", "true", "Determines if minification should be applied to rendered Javascript files."); settings.Add("MinifyStyleSheets", "true", "Determines if minification should be applied to rendered CSS files."); settings.Add("UseMinifyInDebug", "false", "Determines if minification should be applied when running a Debug build."); return new WebServer(FilePath.GetAbsolutePath(settings["WebRootPath"].Value), razorEngineCS, razorEngineVB) { ClientCacheEnabled = settings["ClientCacheEnabled"].Value.ParseBoolean(), MinifyJavascript = settings["MinifyJavascript"].Value.ParseBoolean(), MinifyStyleSheets = settings["MinifyStyleSheets"].Value.ParseBoolean(), UseMinifyInDebug = settings["UseMinifyInDebug"].Value.ParseBoolean() }; }); } }
public Overview(IRazorEngine razorEngine, IDailyHeilContextFactory contextFactory) { _razorEngine = razorEngine; _contextFactory = contextFactory; }