Ejemplo n.º 1
0
 public TemplateModelTransformer(DocumentBuildContext context, TemplateCollection templateCollection, ApplyTemplateSettings settings, IDictionary <string, object> globals)
 {
     _context            = context ?? throw new ArgumentNullException(nameof(context));
     _templateCollection = templateCollection;
     _settings           = settings;
     _globalVariables    = globals;
 }
Ejemplo n.º 2
0
        /// <summary>
        /// TemplateName can be either file or folder
        /// 1. If TemplateName is file, it is considered as the default template
        /// 2. If TemplateName is a folder, files inside the folder is considered as the template, each file is named after {DocumentType}.{extension}
        /// </summary>
        /// <param name="templateName"></param>
        /// <param name="resourceProvider"></param>
        public TemplateProcessor(ResourceCollection resourceProvider, DocumentBuildContext context, int maxParallelism = 0)
        {
            if (maxParallelism <= 0)
            {
                maxParallelism = Environment.ProcessorCount;
            }

            _resourceProvider   = resourceProvider;
            _templateCollection = new TemplateCollection(resourceProvider, context, maxParallelism);
            Tokens = LoadTokenJson(resourceProvider) ?? new Dictionary <string, string>();
        }
Ejemplo n.º 3
0
        /// <summary>
        /// TemplateName can be either file or folder
        /// 1. If TemplateName is file, it is considered as the default template
        /// 2. If TemplateName is a folder, files inside the folder is considered as the template, each file is named after {DocumentType}.{extension}
        /// </summary>
        /// <param name="templateName"></param>
        /// <param name="resourceProvider"></param>
        public TemplateProcessor(ResourceCollection resourceProvider, int maxParallelism = 0)
        {
            if (maxParallelism <= 0)
            {
                maxParallelism = Environment.ProcessorCount;
            }

            _resourceProvider      = resourceProvider;
            _templateCollection    = new TemplateCollection(resourceProvider, maxParallelism);
            DefaultGlobalVariables = LoadGlobalJson(resourceProvider) ?? new Dictionary <string, object>();
        }
Ejemplo n.º 4
0
        public TemplateModelTransformer(DocumentBuildContext context, TemplateCollection templateCollection, ApplyTemplateSettings settings, IDictionary <string, object> globals)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            _context                 = context;
            _templateCollection      = templateCollection;
            _settings                = settings;
            _globalVariables         = globals;
            _systemMetadataGenerator = new SystemMetadataGenerator(context);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// TemplateName can be either file or folder
        /// 1. If TemplateName is file, it is considered as the default template
        /// 2. If TemplateName is a folder, files inside the folder is considered as the template, each file is named after {DocumentType}.{extension}
        /// </summary>
        /// <param name="templateName"></param>
        /// <param name="resourceProvider"></param>
        public TemplateProcessor(ResourceFileReader resourceProvider, DocumentBuildContext context, int maxParallelism = 0)
        {
            if (maxParallelism <= 0)
            {
                maxParallelism = Environment.ProcessorCount;
            }

            _context            = context;
            _resourceProvider   = resourceProvider;
            _maxParallelism     = maxParallelism;
            _templateCollection = new TemplateCollection(resourceProvider, context, maxParallelism);
            Tokens = TemplateProcessorUtility.LoadTokens(resourceProvider) ?? new Dictionary <string, string>();
        }
Ejemplo n.º 6
0
 private IEnumerable <TemplateResourceInfo> ExtractDependentFilePaths(TemplateCollection templates)
 {
     return(templates.Values.SelectMany(s => s).SelectMany(s => s.Resources));
 }
Ejemplo n.º 7
0
 /// <summary>
 /// TemplateName can be either file or folder
 /// 1. If TemplateName is file, it is considered as the default template
 /// 2. If TemplateName is a folder, files inside the folder is considered as the template, each file is named after {DocumentType}.{extension}
 /// </summary>
 /// <param name="templateName"></param>
 /// <param name="resourceProvider"></param>
 public TemplateProcessor(ResourceCollection resourceProvider, int maxParallelism)
 {
     _resourceProvider = resourceProvider;
     _global           = LoadGlobalJson(resourceProvider);
     Templates         = new TemplateCollection(resourceProvider, maxParallelism);
 }