public Specification Compile(XmlElement xmlNode, IXmlSpecificationCompilerContext context) { string units = xmlNode.GetAttribute("units").ToLower(); if (units == null) { throw new XmlSpecificationCompilerException("Xml attribute 'units' is required."); } if (!units.Equals("years") && !units.Equals("weeks") && !units.Equals("days")) { throw new XmlSpecificationCompilerException( "Incorrect value for 'units' Xml attribute. Should be 'years', 'weeks', or 'days'"); } string refValue = GetAttributeOrNull(xmlNode, "refValue"); if (refValue == null) { throw new XmlSpecificationCompilerException("Xml attribute 'refValue' is required."); } return(new DicomAgeLessThanSpecification(units, refValue)); }
public Specification Compile(XmlElement xmlNode, IXmlSpecificationCompilerContext context) { string units = xmlNode.GetAttribute("units").ToLower(); if (units == null) throw new XmlSpecificationCompilerException("Xml attribute 'units' is required."); if (!units.Equals("years") && !units.Equals("weeks") && !units.Equals("days")) throw new XmlSpecificationCompilerException( "Incorrect value for 'units' Xml attribute. Should be 'years', 'weeks', or 'days'"); string refValue = GetAttributeOrNull(xmlNode, "refValue"); if (refValue == null) throw new XmlSpecificationCompilerException("Xml attribute 'refValue' is required."); return new DicomAgeGreaterThanSpecification(units, refValue); }
public XmlSpecificationCompiler( IExpressionFactory defaultExpressionFactory, IEnumerable <IXmlSpecificationCompilerOperator> extensionOperators, ISpecificationProvider resolver = null) { _resolver = resolver ?? new NullResolver(); _defaultExpressionFactory = defaultExpressionFactory; _compilerContext = new Context(this); // declare built-in operators AddOperator(new BuiltInOperator("true", CreateTrue, XmlSpecificationSchema.TrueSchema)); AddOperator(new BuiltInOperator("false", CreateFalse, XmlSpecificationSchema.FalseSchema)); AddOperator(new BuiltInOperator("equal", CreateEqual, XmlSpecificationSchema.EqualSchema)); AddOperator(new BuiltInOperator("not-equal", CreateNotEqual, XmlSpecificationSchema.NotEqualSchema)); AddOperator(new BuiltInOperator("greater-than", CreateGreaterThan, XmlSpecificationSchema.GreaterThanSchema)); AddOperator(new BuiltInOperator("less-than", CreateLessThan, XmlSpecificationSchema.LessThanSchema)); AddOperator(new BuiltInOperator("and", CreateAnd, XmlSpecificationSchema.AndSchema)); AddOperator(new BuiltInOperator("or", CreateOr, XmlSpecificationSchema.OrSchema)); AddOperator(new BuiltInOperator("not", CreateNot, XmlSpecificationSchema.NotSchema)); AddOperator(new BuiltInOperator("regex", CreateRegex, XmlSpecificationSchema.RegexStringMatchingSchema)); AddOperator(new BuiltInOperator("starts-with", CreateStartsWith, XmlSpecificationSchema.StartsWithStringMatchingSchema)); AddOperator(new BuiltInOperator("ends-with", CreateEndsWith, XmlSpecificationSchema.EndsWithStringMatchingSchema)); AddOperator(new BuiltInOperator("contains", CreateContains, XmlSpecificationSchema.ContainsStringMatchingSchema)); AddOperator(new BuiltInOperator("null", CreateIsNull, XmlSpecificationSchema.IsNullSchema)); AddOperator(new BuiltInOperator("not-null", CreateNotNull, XmlSpecificationSchema.NotNullSchema)); AddOperator(new BuiltInOperator("count", CreateCount, XmlSpecificationSchema.CountSchema)); AddOperator(new BuiltInOperator("all", CreateAll, XmlSpecificationSchema.AllSchema)); //note: "each" is a synonym for "all" - "each" is deprecated, but is still supported for backward compatibility AddOperator(new BuiltInOperator("each", CreateAll, XmlSpecificationSchema.EachSchema)); AddOperator(new BuiltInOperator("any", CreateAny, XmlSpecificationSchema.AnySchema)); AddOperator(new BuiltInOperator("case", CreateCase, XmlSpecificationSchema.CaseSchema)); AddOperator(new BuiltInOperator("defined", CreateDefined, XmlSpecificationSchema.DefinedSchema)); // add extension operators foreach (var compilerOperator in extensionOperators) { AddOperator(compilerOperator); } }
public XmlSpecificationCompiler(ISpecificationProvider resolver, IExpressionFactory defaultExpressionFactory) { _resolver = resolver; _defaultExpressionFactory = defaultExpressionFactory; _compilerContext = new Context(this); // declare built-in operators AddOperator(new BuiltInOperator("true", CreateTrue, TrueSchema)); AddOperator(new BuiltInOperator("false", CreateFalse, FalseSchema)); AddOperator(new BuiltInOperator("equal", CreateEqual, EqualSchema)); AddOperator(new BuiltInOperator("not-equal", CreateNotEqual, NotEqualSchema)); AddOperator(new BuiltInOperator("greater-than", CreateGreaterThan, GreaterThanSchema)); AddOperator(new BuiltInOperator("less-than", CreateLessThan, LessThanSchema)); AddOperator(new BuiltInOperator("and", CreateAnd, AndSchema)); AddOperator(new BuiltInOperator("or", CreateOr, OrSchema)); AddOperator(new BuiltInOperator("not", CreateNot, NotSchema)); AddOperator(new BuiltInOperator("regex", CreateRegex, RegexSchema)); AddOperator(new BuiltInOperator("null", CreateIsNull, IsNullSchema)); AddOperator(new BuiltInOperator("not-null", CreateNotNull, NotNullSchema)); AddOperator(new BuiltInOperator("count", CreateCount, CountSchema)); AddOperator(new BuiltInOperator("each", CreateEach, EachSchema)); AddOperator(new BuiltInOperator("any", CreateAny, AnySchema)); AddOperator(new BuiltInOperator("case", CreateCase, CaseSchema)); AddOperator(new BuiltInOperator("defined", CreateDefined, DefinedSchema)); // add extension operators XmlSpecificationCompilerOperatorExtensionPoint xp = new XmlSpecificationCompilerOperatorExtensionPoint(); foreach (IXmlSpecificationCompilerOperator compilerOperator in xp.CreateExtensions()) { AddOperator(compilerOperator); } _schema = CreateSchema(); }
public Specification Compile(XmlElement xmlNode, IXmlSpecificationCompilerContext context) { return(new RequiresOrderIntendedForQCSpecification()); }
public Specification Compile(XmlElement xmlNode, IXmlSpecificationCompilerContext context) { return(_factoryMethod(xmlNode)); }
public Specification Compile(XmlElement xmlNode, IXmlSpecificationCompilerContext context) { return new RequiresOrderIntendedForQCSpecification(); }