Ejemplo n.º 1
0
        /// <summary>
        /// Adds an input or output value to the data grids.
        /// </summary>
        /// <param name="argDesc">The argument description for the argument.</param>
        /// <param name="svDesc">The state variable description for the linked state variable to the argument.</param>
        /// <param name="inputIndex">The current input index.</param>
        /// <param name="outputIndex">The current output index.</param>
        protected void AddIOValue(ArgumentDescription argDesc, StateVariableDescription svDesc, ref int inputIndex, ref int outputIndex)
        {
            StateVariableDataType ldtType;

            // Get the data type for the state variable description
            if (svDesc == null)
                ldtType = StateVariableDataType.tunknown;
            else
                ldtType = svDesc.DataTypeValue;

            switch (argDesc.DirectionValue)
            {
                case ArgumentDirection.In:
                    // If its an input then add it
                    int liIndex = dgInputs.Rows.Add(
                        argDesc.Name,
                        ldtType.Description(),
                        ldtType.StringFromValue(ldtType.Default()));

                    // Set its row info
                    dgInputs.Rows[liIndex].Tag = new RowInfo(argDesc, svDesc, inputIndex);

                    // Increment the input index
                    inputIndex++;

                    break;

                case ArgumentDirection.Out:
                    // If its an output then add it
                    liIndex = dgOutputs.Rows.Add(
                        argDesc.Name,
                        ldtType.Description(),
                        String.Empty);

                    // Set its row info
                    dgOutputs.Rows[liIndex].Tag = new RowInfo(argDesc, svDesc, outputIndex);

                    // Increment the output index
                    outputIndex++;

                    break;
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Generates the code for an out argument which is on its own in the action.
        /// </summary>
        /// <param name="argumentDesc">The argument description.</param>
        /// <param name="outArgumentIndex">The out argument index (0).</param>
        /// <param name="outSetValues">A StringBuilder to append the out set value code to.</param>
        /// <param name="enumStateVar">True if the argument is an enumeration type.</param>
        /// <param name="relatedStateVarFriendlyName">The related state variable code friendly name.</param>
        /// <param name="type">The data type for the argument.</param>
        /// <param name="comments">A StringBuilder to append the comments line for the return parameter to.</param>
        private void GenerateOutArgumentReturnCode(
            ArgumentDescription argumentDesc,
            int outArgumentIndex, StringBuilder outSetValues, bool enumStateVar,
            string relatedStateVarFriendlyName, string type, StringBuilder comments)
        {
            // Generate argument comment line
            comments.Append(
                string.Format(
                    CodeGenProvider.ActionReturnsComment,
                    relatedStateVarFriendlyName,
                    GenerateArgumentDescriptionComment(argumentDesc)
                )
            );

            // Generate the return statement code
            if (enumStateVar)
                outSetValues.Append(string.Format(CodeGenProvider.OutReturnValueEnum, relatedStateVarFriendlyName, outArgumentIndex));
            else
                outSetValues.Append(string.Format(CodeGenProvider.OutReturnValue, type, outArgumentIndex));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Generates the code for an out argument which is NOT on its own in the action.
        /// </summary>
        /// <param name="argumentDesc">The argument description.</param>
        /// <param name="outArgumentIndex">The out argument index (0).</param>
        /// <param name="outArguments">A StringBuilder to append the out arguments to.</param>
        /// <param name="outSetValues">A StringBuilder to append the out set value code to.</param>
        /// <param name="enumStateVar">True if the argument is an enumeration type.</param>
        /// <param name="argFriendlyName">The code friendly name of the out argument.</param>
        /// <param name="relatedStateVarFriendlyName">The related state variable code friendly name.</param>
        /// <param name="type">The data type for the argument.</param>
        /// <param name="comments">A StringBuilder to append the comments line for the parameter to.</param>
        private void GenerateOutArgumentCode(
            ArgumentDescription argumentDesc,
            int outArgumentIndex, StringBuilder outArguments, StringBuilder outSetValues, bool enumStateVar,
            string argFriendlyName, string relatedStateVarFriendlyName, string type, StringBuilder comments)
        {
            // Generate argument comment line
            comments.Append(
                string.Format(
                    CodeGenProvider.ActionOutParamComment,
                    argFriendlyName,
                    GenerateArgumentDescriptionComment(argumentDesc)
                )
            );

            // Generate argument definition
            outArguments.Append(
                string.Format(
                    CodeGenProvider.ActionOutArgument,
                    type, argFriendlyName,
                    (outArguments.Length > 0 ? CodeGenProvider.ParameterSeperator : String.Empty)
                )
            );

            // Generate out set value code
            if (enumStateVar)
                outSetValues.Append(
                    string.Format(
                        CodeGenProvider.OutSetValueEnum,
                        argFriendlyName,
                        relatedStateVarFriendlyName,
                        outArgumentIndex
                    )
                );
            else
                outSetValues.Append(
                    string.Format(
                        CodeGenProvider.OutSetValue,
                        argFriendlyName,
                        type,
                        outArgumentIndex
                    )
                );
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Generates the code for an in argument.
        /// </summary>
        /// <param name="argumentDesc">The argument description.</param>
        /// <param name="inArgumentIndex">The argument index.</param>
        /// <param name="inArguments">The StringBuilder to append the argument definition to.</param>
        /// <param name="inSetValues">The StringBuilder to append the argument set values to.</param>
        /// <param name="enumStateVar">True if the state variable is an enumeration type.</param>
        /// <param name="argFriendlyName">The code friendly argument name.</param>
        /// <param name="relatedStateVarFriendlyName">The related state variable code friendly name.</param>
        /// <param name="type">The data type for the argument.</param>
        /// <param name="comments">A StringBuilder to append the comments line for the parameter to.</param>
        private void GenerateInArgumentCode(
            ArgumentDescription argumentDesc,
            int inArgumentIndex, StringBuilder inArguments, StringBuilder inSetValues,
            bool enumStateVar, string argFriendlyName, string relatedStateVarFriendlyName,
            string type, StringBuilder comments)
        {
            // Generate argument comment line
            comments.Append(
                string.Format(
                    CodeGenProvider.ActionInParamComment,
                    argFriendlyName,
                    GenerateArgumentDescriptionComment(argumentDesc)
                )
            );

            // Generate argument definition
            inArguments.Append(
                string.Format(
                    CodeGenProvider.ActionInArgument,
                    type, argFriendlyName,
                    (inArguments.Length > 0 ? CodeGenProvider.ParameterSeperator : String.Empty)
                )
            );

            // Generate in set value code
            if (enumStateVar)
                inSetValues.Append(
                    string.Format(
                        CodeGenProvider.InSetValueEnum,
                        inArgumentIndex,
                        relatedStateVarFriendlyName,
                        argFriendlyName
                    )
                );
            else
                inSetValues.Append(
                    string.Format(
                        CodeGenProvider.InSetValue,
                        inArgumentIndex,
                        argFriendlyName
                    )
                );
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Generates the comments for an actions method argument including its name.
        /// </summary>
        /// <param name="argumentDesc">The argument description describing the argument of the action.</param>
        /// <returns>A string containing a single line comment.</returns>
        private string GenerateArgumentDescriptionComment(ArgumentDescription argumentDesc)
        {
            StateVariableDescription lsdDesc = argumentDesc.RelatedStateVariableDescription;

            return string.Format(
                CodeGenProvider.ArgumentComment,
                argumentDesc.Name,
                GenerateStateVariableDescriptionComment(lsdDesc));
        }
Ejemplo n.º 6
0
 /// <summary>
 /// Creates a new row info structure.
 /// </summary>
 /// <param name="argDesc">The argument description for the input or output.</param>
 /// <param name="stateVarDesc">The state variable description for the input or output.</param>
 /// <param name="index">The index of the input or output.</param>
 public RowInfo(ArgumentDescription argDesc, StateVariableDescription stateVarDesc, int index)
 {
     madArgDesc = argDesc;
     msvStateVarDesc = stateVarDesc;
     miIndex = index;
 }