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="builder">Builder to be used to fully configure the expression decision 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 WithExpressionDecision(string name, Func <ExpressionDecision.ExpressionDecisionSrcBuilder, ExpressionDecision> 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 ExpressionDecision(Variables, Decisions, name);

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

            return(this);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// CTOR
 /// </summary>
 /// <param name="decision">"Parent" expression decision builder</param>
 internal ExpressionDecisionVarBuilder(ExpressionDecision decision)
 {
     Decision = decision;
 }