/// <summary>
        /// Compile the DbContext template.
        /// </summary>
        /// <returns>DbContext template.</returns>
        protected virtual Func <object, string> CompileDbContextTemplate()
        {
            var template = FileService.RetrieveTemplateFileContents(
                Constants.DbContextDirectory,
                Constants.DbContextTemplate + Constants.TemplateExtension);
            var contextTemplate = HandlebarsLib.Compile(template);

            return(contextTemplate);
        }
        /// <summary>
        /// Compile entity type template.
        /// </summary>
        /// <param name="language">Language option.</param>
        /// <returns>Entity type template.</returns>
        protected virtual Func <object, string> CompileEntityTypeTemplate(
            LanguageOptions language = LanguageOptions.CSharp)
        {
            EntitiesTemplateFiles.TryGetValue(Constants.EntityTypeTemplate, out TemplateFileInfo classFile);
            var entityTemplateFile = FileService.RetrieveTemplateFileContents(
                classFile.RelativeDirectory, classFile.FileName);
            var entityTemplate = HandlebarsLib.Compile(entityTemplateFile);

            return(entityTemplate);
        }
Exemple #3
0
        /// <summary>
        /// Compile the DbContext template.
        /// </summary>
        /// <param name="language">Language option.</param>
        /// <returns>DbContext template.</returns>
        protected virtual Func <object, string> CompileDbContextTemplate(
            LanguageOptions language = LanguageOptions.CSharp)
        {
            DbContextTemplateFiles.TryGetValue(Constants.DbContextTemplate, out TemplateFileInfo contextFile);
            var contextTemplateFile = FileService.RetrieveTemplateFileContents(
                contextFile.RelativeDirectory, contextFile.FileName);
            var contextTemplate = HandlebarsLib.Compile(contextTemplateFile);

            return(contextTemplate);
        }
Exemple #4
0
 public Action <TextWriter, string> CompileTemplateToWriter()
 {
     using (var reader = new StreamReader(_file.OpenRead())) {
         return(Hbs.Compile(reader));
     }
 }
Exemple #5
0
        public Func <object, string> CompileTemplate()
        {
            var template = ReadTemplate();

            return(Hbs.Compile(template));
        }
Exemple #6
0
        public string RenderTemplate(object data)
        {
            var compiled = Hbs.Compile(ReadTemplate());

            return(compiled(data));
        }