Beispiel #1
0
        internal OperationOutcome ValidateBinding(ElementDefinition definition, ITypedElement instance)
        {
            var outcome = new OperationOutcome();

            if (definition.Binding == null)
            {
                return(outcome);
            }

            var ts = Settings.TerminologyService;

            if (ts == null)
            {
                if (Settings.ResourceResolver == null)
                {
                    Trace(outcome, $"Cannot resolve binding references since neither TerminologyService nor ResourceResolver is given in the settings",
                          Issue.UNAVAILABLE_TERMINOLOGY_SERVER, instance);
                    return(outcome);
                }

                ts = new LocalTerminologyService(Settings.ResourceResolver);
            }

            var bindingValidator = new BindingValidator(ts, instance.Location);

            try
            {
                Element bindable = instance.ParseBindable();

                // If the instance is not bindeable, ignore the Binding specified on the element,
                // it's simply not applicable
                if (bindable != null)
                {
                    return(bindingValidator.ValidateBinding(bindable, definition.Binding));
                }
            }
            catch (Exception e)
            {
                Trace(outcome, $"Terminology service call failed for binding at {definition.Path}: {e.Message}", Issue.TERMINOLOGY_SERVICE_FAILED, instance);
            }

            return(outcome);
        }