コード例 #1
0
 public void ValidateConstraint(Element element, Constraint constraint)
 {
     if (constraint.IsValid)
     {
         
         Log(Group.Constraint, Status.Valid, "Constraint is valid");
     }
     else 
     {
          Log(Group.Constraint, Status.Failed, 
              "Constraint [{0}] ({1}) has an invalid XPath: {2}", 
              constraint.Name, constraint.HumanReadable, constraint.CompilerError.Message);
     }
 }
コード例 #2
0
        private void HarvestConstraints(Hl7.Fhir.Model.Profile.ElementDefinitionComponent source, Element target)
        {
            if (source.Constraint == null)
                return;

            foreach (Hl7.Fhir.Model.Profile.ElementDefinitionConstraintComponent c in source.Constraint)
            {
                Constraint constraint = new Constraint();
                constraint.Name = c.Name ?? c.Key;
                constraint.XPath = c.Xpath;
                constraint.HumanReadable = c.Human;
                target.Constraints.Add(constraint);
            }
        }
コード例 #3
0
        public void ValidateConstraint(Vector vector, Constraint constraint)
        {
            if (constraint.IsValid)
            {
                try
                {
                    bool valid = vector.Evaluate(constraint);

                    if (valid)
                        Log(Group.Constraint, Status.Valid, vector, "Node [{0}] conforms to constraint [{1}]", vector.Node.Name, constraint.Name);
                    else
                        Log(Group.Constraint, Status.Failed, vector, "Node [{0}] does not conform to constraint [{1}]: \"{2}\" ", vector.Node.Name, constraint.Name, constraint.HumanReadable);
                }
                catch (XPathException e)
                {
                    Log(Group.Constraint, Status.Failed, vector, "Evaluation of constraint [{0}] evaluation failed: {1}", constraint.Name, e.Message);
                }
            }
        }
コード例 #4
0
ファイル: Vector.cs プロジェクト: tiloc/fhir-net-api
 public bool Evaluate(Constraint constraint)
 {
     bool valid = (bool)Node.Evaluate(constraint.Expression);
     return valid;
 }