Esempio n. 1
0
        /// <summary>
        /// Sets the constraint parameter value.
        /// </summary>
        /// <param name="constraintName">The name of the constraint to return.</param>
        /// <param name="definitionUniqueId">The name of the definition to return.</param>
        /// <param name="parameterName">The name of the parameter to return.</param>
        /// <param name="dataValueType">The name of the parameter to return.</param>
        /// <returns>Returns the specified constrainst parameter.</returns>
        public IDataElement AddConstraintParameter(
            string constraintName,
            string definitionUniqueId    = null,
            string parameterName         = null,
            DataValueTypes dataValueType = DataValueTypes.Any)
        {
            IDataElement dataElement = null;

            IBdoRoutineConfiguration routine = GetConstraint(constraintName);

            if ((routine == null) || (!routine.DefinitionUniqueId.KeyEquals(definitionUniqueId)))
            {
                routine = AddConstraint(constraintName, definitionUniqueId);
            }

            if (routine != null)
            {
                if (parameterName == null && routine.Count > 0)
                {
                    dataElement = routine[0];
                }
                else
                {
                    dataElement = routine[parameterName];
                }
                if (dataElement == null)
                {
                    routine.Add(dataElement = ElementFactory.CreateScalar(
                                    parameterName,
                                    dataValueType == DataValueTypes.Any ? dataValueType.GetValueType() : dataValueType));
                }
            }

            return(dataElement);
        }
Esempio n. 2
0
        /// <summary>
        /// Sets the constraint parameter value.
        /// </summary>
        /// <param name="constraintName">The name of the constraint to return.</param>
        /// <param name="definitionUniqueId">The name of the definition to return.</param>
        /// <param name="parameterName">The name of the parameter to return.</param>
        /// <param name="value">The value to consider.</param>
        /// <param name="dataValueType">The name of the parameter to return.</param>
        /// <returns>Returns the specified constrainst parameter.</returns>
        public bool SetConstraintParameterValue(
            string constraintName,
            string definitionUniqueId = null,
            string parameterName      = null,
            object value = null,
            DataValueTypes dataValueType = DataValueTypes.Any)
        {
            IBdoRoutineConfiguration routine = GetConstraint(constraintName);

            if (routine?.DefinitionUniqueId.KeyEquals(definitionUniqueId) != true)
            {
                routine = AddConstraint(constraintName, definitionUniqueId);
            }

            IDataElement dataElement;

            if (parameterName == null && routine.Count > 0)
            {
                dataElement = routine[0];
            }
            else
            {
                dataElement = routine[parameterName];
            }
            if (dataElement == null)
            {
                routine.Add(
                    ElementFactory.CreateScalar(
                        parameterName,
                        dataValueType == DataValueTypes.Any ? value.GetValueType() : dataValueType,
                        value));
            }
            else
            {
                dataElement.WithItems(value);
            }

            return(true);
        }