예제 #1
0
        public override string GetMethodSignature(MethodInfo info, bool fullForm)
        {
            string result    = info.Name + "(";
            string fontBegin = "<font color=\"Blue\">";
            string fontEnd   = "</font>";

            System.Reflection.ParameterInfo[] pars = info.GetParameters();
            foreach (System.Reflection.ParameterInfo par in pars)
            {
                // special case - skip "thisReport" parameter
                if (par.Name == "thisReport")
                {
                    continue;
                }

                string modifier = "ByVal";
                if (par.IsOptional)
                {
                    modifier = "Optional " + modifier;
                }
                object[] attr = par.GetCustomAttributes(typeof(ParamArrayAttribute), false);
                if (attr.Length > 0)
                {
                    modifier += " ParamArray";
                }
                result += fullForm ? fontBegin + modifier + fontEnd + " " + par.Name + " " + fontBegin + "As" + fontEnd + " " : "";
                result += (fullForm ? fontBegin : "") + GetEquivalentKeyword(par.ParameterType.Name) + (fullForm ? fontEnd : "");
#if DOTNET_4
                if (par.IsOptional && fullForm)
                {
                    result += CodeUtils.GetOptionalParameter(par, CodeUtils.Language.Vb);
                }
#endif
                result += ", ";
            }

            if (result.EndsWith(", "))
            {
                result = result.Substring(0, result.Length - 2);
            }

            result += ")";
            if (fullForm)
            {
                result += " " + fontBegin + "As " + info.ReturnType.Name + fontEnd;
            }
            return(result);
        }
예제 #2
0
        private string ReplaceDataItems(string expression)
        {
            FindTextArgs args = new FindTextArgs();

            args.Text         = new FastString(expression);
            args.OpenBracket  = "[";
            args.CloseBracket = "]";

            while (args.StartIndex < args.Text.Length)
            {
                expression = CodeUtils.GetExpression(args, true);
                if (expression == "")
                {
                    break;
                }

                if (DataHelper.IsValidColumn(Report.Dictionary, expression))
                {
                    Type type = DataHelper.GetColumnType(Report.Dictionary, expression);
                    expression = Report.CodeHelper.ReplaceColumnName(expression, type);
                }
                else if (DataHelper.IsValidParameter(Report.Dictionary, expression))
                {
                    expression = Report.CodeHelper.ReplaceParameterName(DataHelper.GetParameter(Report.Dictionary, expression));
                }
                else if (DataHelper.IsValidTotal(Report.Dictionary, expression))
                {
                    expression = Report.CodeHelper.ReplaceTotalName(expression);
                }
                else
                {
                    expression = "[" + ReplaceDataItems(expression) + "]";
                }

                args.Text        = args.Text.Remove(args.StartIndex, args.EndIndex - args.StartIndex);
                args.Text        = args.Text.Insert(args.StartIndex, expression);
                args.StartIndex += expression.Length;
            }
            return(args.Text.ToString());
        }
예제 #3
0
        public override string GetMethodSignatureAndBody(MethodInfo info)
        {
            string result = info.Name + "(";

            result = "    private " + GetTypeDeclaration(info.ReturnType) + " " + result;

            System.Reflection.ParameterInfo[] pars = info.GetParameters();
            foreach (System.Reflection.ParameterInfo par in pars)
            {
                // special case - skip "thisReport" parameter
                if (par.Name == "thisReport")
                {
                    continue;
                }

                string   paramType = "";
                object[] attr      = par.GetCustomAttributes(typeof(ParamArrayAttribute), false);
                if (attr.Length > 0)
                {
                    paramType = "params ";
                }
                paramType += GetTypeDeclaration(par.ParameterType);
                result    += paramType;
                result    += " " + par.Name;
#if DOTNET_4
                if (par.IsOptional)
                {
                    result += CodeUtils.GetOptionalParameter(par, CodeUtils.Language.Cs);
                }
#endif
                result += ", ";
            }

            if (result.EndsWith(", "))
            {
                result = result.Substring(0, result.Length - 2);
            }
            result += ")";

            result += "\r\n";
            result += "    {\r\n";
            result += "      return " + info.ReflectedType.Namespace + "." +
                      info.ReflectedType.Name + "." + info.Name + "(";

            foreach (System.Reflection.ParameterInfo par in pars)
            {
                string parName = par.Name;
                // special case - handle "thisReport" parameter
                if (parName == "thisReport")
                {
                    parName = "Report";
                }
                result += parName + ", ";
            }

            if (result.EndsWith(", "))
            {
                result = result.Substring(0, result.Length - 2);
            }
            result += ");\r\n";
            result += "    }\r\n";
            result += "\r\n";

            return(result);
        }
예제 #4
0
        public override string GetMethodSignatureAndBody(MethodInfo info)
        {
            string result = info.Name + "(";

            result = "    Private Function " + result;

            System.Reflection.ParameterInfo[] pars = info.GetParameters();
            foreach (System.Reflection.ParameterInfo par in pars)
            {
                // special case - skip "thisReport" parameter
                if (par.Name == "thisReport")
                {
                    continue;
                }

                string parName  = "_" + par.Name;
                string modifier = "ByVal";
                if (par.IsOptional)
                {
                    modifier = "Optional " + modifier;
                }
                object[] attr = par.GetCustomAttributes(typeof(ParamArrayAttribute), false);
                if (attr.Length > 0)
                {
                    modifier += " ParamArray";
                }
                result += modifier + " " + parName + " As ";
                result += GetTypeDeclaration(par.ParameterType);
#if DOTNET_4
                if (par.IsOptional)
                {
                    result += CodeUtils.GetOptionalParameter(par, CodeUtils.Language.Vb);
                }
#endif
                result += ", ";
            }

            if (result.EndsWith(", "))
            {
                result = result.Substring(0, result.Length - 2);
            }
            result += ")";

            result += " As " + GetTypeDeclaration(info.ReturnType);
            result += "\r\n";
            result += "      Return Global." + info.ReflectedType.Namespace + "." +
                      info.ReflectedType.Name + "." + info.Name + "(";

            foreach (System.Reflection.ParameterInfo par in pars)
            {
                string parName = "_" + par.Name;
                // special case - handle "thisReport" parameter
                if (parName == "_thisReport")
                {
                    parName = "Report";
                }

                result += parName + ", ";
            }

            if (result.EndsWith(", "))
            {
                result = result.Substring(0, result.Length - 2);
            }
            result += ")\r\n";
            result += "    End Function\r\n";
            result += "\r\n";

            return(result);
        }