예제 #1
0
        /// <summary>
        /// Adds the expression based table input
        /// </summary>
        /// <remarks>The inputs are "indexed" in the order as added to the table definition builder</remarks>
        /// <param name="expression">Expression to be used as table input</param>
        /// <param name="inputRef">Reference to added table input that can be used in rule builders</param>
        /// <param name="allowedValues">Allowed input values</param>
        /// <exception cref="DmnBuilderException">Throws <see cref="DmnBuilderException"/> when the definition has already been built</exception>
        /// <exception cref="ArgumentNullException"> when the <paramref name="expression"/> is not provided</exception>
        /// <exception cref="ArgumentException"> when the <paramref name="expression"/> is empty or whitespace</exception>
        public TableDecision WithInput(string expression, out TableInput.Ref inputRef, params string[] allowedValues)
        {
            if (IsBuilt)
            {
                throw Logger.Error <DmnBuilderException>($"Decision is already built");
            }
            if (expression == null)
            {
                throw new ArgumentNullException(nameof(expression));
            }
            if (string.IsNullOrWhiteSpace(expression))
            {
                throw new ArgumentException("Missing expression", nameof(expression));
            }

            var input = new TableInput(Variables, Decisions, InputsInternal.Count).WithExpression(expression);

            _ = allowedValues != null && allowedValues.Length > 0
                ? input.WithAllowedValues(allowedValues)
                : input.WithoutAllowedValuesConstraint();

            inputRef = input.Reference;
            InputsInternal.Add(input);
            InputsByRef.Add(inputRef, input);
            return(this);
        }
예제 #2
0
 /// <summary>
 /// Private CTOR - accessible from "owner class" via <see cref="RefCtor"/>
 /// </summary>
 /// <param name="input">Table input to create the reference for</param>
 private Ref(TableInput input)
 {
     Input = input;
 }