Esempio n. 1
0
        public Template <TModel> GetTemplate <TModel>(TModel model, string key, IEnumerable <string> tags = null, CultureInfo culture = null)
        {
            var template = _templateFactory.Create <TModel>(key, tags);

            if (culture != null)
            {
                template.Culture = culture;
            }
            template.Model = model;
            template.Texts = _texts;
            return(template);
        }
Esempio n. 2
0
        public IEnumerable <ITemplate> Load()
        {
            var folders = new[]
            {
                new Tuple <string, TemplateType>("build", TemplateType.Build),
                new Tuple <string, TemplateType>("source", TemplateType.Source)
            };

            var result = new List <ITemplate>();

            folders.ForEach(
                item =>
                _fileManager.EnumerateDirectories(Path.Combine(_context.TemplateDirectory.FullName, item.Item1),
                                                  "*.*", SearchOption.TopDirectoryOnly).ForEach(
                    directory => result.Add(_templateFactory.Create(new DirectoryInfo(directory), item.Item2))));
            return(result);
        }
Esempio n. 3
0
        private ILookupTemplate <IFhirTemplate> LoadFhirTemplate(string fhirMappingContent, TemplateResult validationResult)
        {
            try
            {
                var fhirTemplateContext = _fhirTemplateFactory.Create(fhirMappingContent);

                if (fhirTemplateContext is TemplateContext <ILookupTemplate <IFhirTemplate> > contentTemplateContext)
                {
                    CaptureTemplateErrors(validationResult, contentTemplateContext, ValidationCategory.FHIRTRANSFORMATION);
                }

                return(fhirTemplateContext.Template);
            }
            catch (Exception e)
            {
                validationResult.CaptureException(e, ValidationCategory.FHIRTRANSFORMATION);
            }

            return(null);
        }
Esempio n. 4
0
        public Template Activate(Type templateType, TemplateContext context)
        {
            Contract.Requires(templateType != null);
            Contract.Requires(context != null);

            Template template = null;

            try
            {
                template = _templateFactory.Create(templateType, context);
            }
            catch (Exception ex)
            {
                throw new ActivatorException(templateType, ex);
            }
            if (template == null)
            {
                throw new ActivatorException(templateType);
            }
            return(template);
        }
Esempio n. 5
0
 public static TemplateFactoryResult Create(this ITemplateFactory engine, FileInfo file)
 => engine.Create(File.ReadAllText(file.FullName));
 public override TOutput Create(TInput input) => _contentTemplateFactory.Create(input);