Пример #1
0
        /// <summary>
        /// Creates a function which gets the field named "fieldName" from one of the subfield of the structure provided as parameter
        /// </summary>
        /// <param name="nameSpace">The namespace in which the function should be created</param>
        /// <param name="structure">The structure which should be looked for</param>
        /// <param name="subField">The name of the subfield to look for</param>
        /// <param name="returnType">The function return type</param>
        private void AppendGetFunction(DataDictionary.Types.NameSpace nameSpace, DataDictionary.Types.Structure structure, string subField, string returnType)
        {
            DataDictionary.Functions.Function getFunction = (DataDictionary.Functions.Function)DataDictionary.Generated.acceptor.getFactory().createFunction();
            getFunction.Name = subField;
            getFunction.setTypeName(returnType);

            DataDictionary.Parameter param = (DataDictionary.Parameter)DataDictionary.Generated.acceptor.getFactory().createParameter();
            param.Name     = "msg";
            param.TypeName = structure.Name;
            getFunction.appendParameters(param);

            foreach (DataDictionary.Types.StructureElement element in structure.Elements)
            {
                DataDictionary.Functions.Case     cas       = (DataDictionary.Functions.Case)DataDictionary.Generated.acceptor.getFactory().createCase();
                DataDictionary.Rules.PreCondition condition = (DataDictionary.Rules.PreCondition)DataDictionary.Generated.acceptor.getFactory().createPreCondition();
                condition.Expression = "msg." + element.Name + " != EMPTY";

                cas.appendPreConditions(condition);
                cas.ExpressionText = "msg." + element.Name + "." + subField;

                getFunction.appendCases(cas);
            }

            nameSpace.appendFunctions(getFunction);
        }
Пример #2
0
        /// <summary>
        ///     Creates a precondition in the enclosing function case
        /// </summary>
        /// <param name="enclosing"></param>
        /// <param name="name"></param>
        /// <returns></returns>
        protected PreCondition CreatePreCondition(Case enclosing, string name)
        {
            PreCondition retVal = (PreCondition)Factory.createPreCondition();

            enclosing.appendPreConditions(retVal);
            retVal.ExpressionText = name;

            return(retVal);
        }
Пример #3
0
        /// <summary>
        ///     Creates a case in the enclosing function
        /// </summary>
        /// <param name="function"></param>
        /// <param name="name"></param>
        /// <param name="expression"></param>
        /// <param name="preConditionExpression"></param>
        /// <returns></returns>
        protected Case CreateCase(Function function, string name, string expression, string preConditionExpression = "")
        {
            Case retVal = (Case)Factory.createCase();

            function.appendCases(retVal);
            retVal.Name           = name;
            retVal.ExpressionText = expression;

            if (preConditionExpression != "")
            {
                PreCondition preCondition = (PreCondition)Factory.createPreCondition();
                preCondition.ExpressionText = preConditionExpression;
                retVal.appendPreConditions(preCondition);
            }

            return(retVal);
        }
        /// <summary>
        ///     Creates a precondition in the enclosing function case
        /// </summary>
        /// <param name="enclosing"></param>
        /// <param name="name"></param>
        /// <returns></returns>
        protected PreCondition CreatePreCondition(Case enclosing, string name)
        {
            PreCondition retVal = (PreCondition) Factory.createPreCondition();
            enclosing.appendPreConditions(retVal);
            retVal.ExpressionText = name;

            return retVal;
        }