protected override ILookupTemplate <IFhirTemplate> BuildCollectionTemplate(JArray templateCollection, ICollection <TemplateError> errors)
        {
            EnsureArg.IsNotNull(templateCollection, nameof(templateCollection));
            EnsureArg.IsNotNull(errors, nameof(errors));

            var lookupTemplate = new FhirLookupTemplate();

            foreach (var token in templateCollection)
            {
                try
                {
                    var container       = token.ToObject <TemplateContainer>();
                    var createdTemplate = TemplateFactories.Evaluate(container);
                    lookupTemplate.RegisterTemplate(createdTemplate);
                }
                catch (InvalidTemplateException ex)
                {
                    errors.Add(new TemplateError(ex.Message));
                }
                catch (JsonSerializationException ex)
                {
                    errors.Add(new TemplateError(ex.Message));
                }
            }

            return(lookupTemplate);
        }
        protected override ILookupTemplate<IFhirTemplate> BuildCollectionTemplate(JArray templateCollection)
        {
            var lookupTemplate = new FhirLookupTemplate();
            foreach (var token in templateCollection)
            {
                var container = token.ToObject<TemplateContainer>();
                var createdTemplate = TemplateFactories.Evaluate(container);
                lookupTemplate.RegisterTemplate(createdTemplate);
            }

            return lookupTemplate;
        }
Ejemplo n.º 3
0
        protected override IContentTemplate BuildCollectionTemplate(JArray templateCollection)
        {
            var template = new CollectionContentTemplate();

            foreach (var token in templateCollection)
            {
                var container       = token.ToObject <TemplateContainer>();
                var createdTemplate = TemplateFactories.Evaluate(container);
                template.RegisterTemplate(createdTemplate);
            }

            return(template);
        }
Ejemplo n.º 4
0
        protected override ILookupTemplate <IFhirTemplate> BuildCollectionTemplate(JArray templateCollection, ICollection <TemplateError> errors)
        {
            EnsureArg.IsNotNull(templateCollection, nameof(templateCollection));
            EnsureArg.IsNotNull(errors, nameof(errors));

            var lookupTemplate = new FhirLookupTemplate();

            foreach (var token in templateCollection)
            {
                try
                {
                    var container       = token.ToObject <TemplateContainer>();
                    var createdTemplate = TemplateFactories.Evaluate(container);
                    lookupTemplate.RegisterTemplate(createdTemplate);
                }
                catch (InvalidTemplateException ex)
                {
                    errors.Add(new TemplateError(ex.Message, ex.GetLineInfo));
                }
                catch (JsonSerializationException ex)
                {
                    errors.Add(new TemplateError(ex.Message, new LineInfo()
                    {
                        LineNumber = ex.LineNumber, LinePosition = ex.LinePosition
                    }));
                }
                catch (AggregateException ex)
                {
                    foreach (var error in ex.ConvertExceptionToTemplateErrors())
                    {
                        errors.Add(error);
                    }
                }
            }

            return(lookupTemplate);
        }