Пример #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 parameter in the enclosing function
        /// </summary>
        /// <param name="function"></param>
        /// <param name="name"></param>
        /// <param name="type"></param>
        /// <returns></returns>
        protected Parameter CreateParameter(Function function, string name, string type)
        {
            Parameter retVal = (Parameter)Factory.createParameter();

            function.appendParameters(retVal);
            retVal.Name     = name;
            retVal.TypeName = type;

            return(retVal);
        }
        /// <summary>
        ///     Creates a parameter in the enclosing function
        /// </summary>
        /// <param name="function"></param>
        /// <param name="name"></param>
        /// <param name="type"></param>
        /// <returns></returns>
        protected Parameter CreateParameter(Function function, string name, string type)
        {
            Parameter retVal = (Parameter) Factory.createParameter();
            function.appendParameters(retVal);
            retVal.Name = name;
            retVal.TypeName = type;

            return retVal;
        }