Ejemplo n.º 1
0
 /// <summary>
 /// Adds the expression decision into the definition
 /// </summary>
 /// <param name="name">Name of the decision to add</param>
 /// <param name="expression">Expression to be evaluated during the decision execution</param>
 /// <param name="outputVariable">Reference to existing variable to store the output of the decision evaluation</param>
 /// <param name="decisionRef">Reference to the decision added</param>
 /// <returns>The current <see cref="DmnDefinitionBuilder"/></returns>
 /// <exception cref="DmnBuilderException">Throws <see cref="DmnBuilderException"/> when the definition has already been built</exception>
 public DmnDefinitionBuilder WithExpressionDecision(string name, string expression, Variable.Ref outputVariable, out Decision.Ref decisionRef)
 {
     return(WithExpressionDecision(name, e => e.Put(expression).To(outputVariable), out decisionRef));
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Adds the decision table into the definition
        /// </summary>
        /// <param name="name">Name of the decision table to add</param>
        /// <param name="builder">Builder to be used to fully configure the decision table definition</param>
        /// <param name="decisionRef">Reference to the decision added</param>
        /// <returns>The current <see cref="DmnDefinitionBuilder"/></returns>
        /// <exception cref="DmnBuilderException">Throws <see cref="DmnBuilderException"/> when the definition has already been built</exception>
        public DmnDefinitionBuilder WithTableDecision(string name, Func <TableDecision, TableDecision> builder, out Decision.Ref decisionRef)
        {
            if (IsBuilt)
            {
                throw Logger.Error <DmnBuilderException>("Definition is already built");
            }
            if (name == null)
            {
                throw new ArgumentNullException(nameof(name));
            }
            if (string.IsNullOrWhiteSpace(name))
            {
                throw new ArgumentException("Missing decision name", nameof(name));
            }
            if (builder is null)
            {
                throw new ArgumentNullException(nameof(builder));
            }

            if (Decisions.Decisions.ContainsKey(name))
            {
                throw Logger.Error <DmnBuilderException>($"Decision {name} already exists");
            }

            var decision = new TableDecision(Variables, Decisions, name);

            decisionRef = decision.Reference;
            Decisions.AddDecision(decision);
            builder.Invoke(decision);

            return(this);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Retrieves the <see cref="Decision"/> definition builder by its <see cref="Decision.Ref">reference</see>
 /// </summary>
 /// <param name="reference">Decision definition builder reference</param>
 /// <returns>Decision definition builder or null when the reference is not found</returns>
 public Decision this[Decision.Ref reference] =>
 DecisionsByRef.TryGetValue(reference, out var decision) ? decision : null;