Пример #1
0
        /// <summary>
        /// Adds the table output with reference to the variable to store the output value to
        /// </summary>
        /// <remarks>The outputs are "indexed" in the order as added to the table definition builder</remarks>
        /// <param name="variableRef">Reference to variable used to store the table output to</param>
        /// <param name="outputRef">Reference to added table output that can be used in rule builders</param>
        /// <param name="allowedValues">Allowed output values</param>
        /// <exception cref="DmnBuilderException">Throws <see cref="DmnBuilderException"/> when the definition has already been built</exception>
        /// <exception cref="ArgumentNullException"> when the <paramref name="variableRef"/> is not provided</exception>
        public TableDecision WithOutput(Variable.Ref variableRef, out TableOutput.Ref outputRef, params string[] allowedValues)
        {
            if (IsBuilt)
            {
                throw Logger.Error <DmnBuilderException>($"Decision is already built");
            }
            if (variableRef == null)
            {
                throw new ArgumentNullException(nameof(variableRef));
            }

            var output = new TableOutput(Variables, Decisions, OutputsInternal.Count).WithVariable(variableRef);

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

            outputRef = output.Reference;
            OutputsInternal.Add(output);
            OutputsByRef.Add(outputRef, output);
            return(this);
        }
Пример #2
0
 /// <summary>
 /// Private CTOR - accessible from "owner class" via <see cref="RefCtor"/>
 /// </summary>
 /// <param name="output">Table output to create the reference for</param>
 private Ref(TableOutput output)
 {
     Output = output;
 }