/// <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); }
/// <summary> /// Creates a function in the enclosing namespace /// </summary> /// <param name="enclosing"></param> /// <param name="name"></param> /// <param name="typeName"></param> /// <returns></returns> protected Function CreateFunction(NameSpace enclosing, string name, string typeName) { Function retVal = (Function)Factory.createFunction(); enclosing.appendFunctions(retVal); retVal.Name = name; retVal.TypeName = typeName; return(retVal); }
/// <summary> /// Creates a function in the enclosing namespace /// </summary> /// <param name="enclosing"></param> /// <param name="name"></param> /// <param name="typeName"></param> /// <returns></returns> protected Function CreateFunction(NameSpace enclosing, string name, string typeName) { Function retVal = (Function) Factory.createFunction(); enclosing.appendFunctions(retVal); retVal.Name = name; retVal.TypeName = typeName; return retVal; }