コード例 #1
0
        private static void AppendParameterInfo(StringBuilder toolTipText, ParameterInfo parameterInfo, bool isLastParameter)
        {
            Type paramType = parameterInfo.ParameterType;

            if (paramType != null)
            {
                if (paramType.IsByRef)
                {
                    if (parameterInfo.IsOut)
                    {
                        toolTipText.Append("out ");
                    }
                    else
                    {
                        toolTipText.Append("ref ");
                    }

                    paramType = paramType.GetElementType();
                }
                else if (isLastParameter && paramType.IsArray)
                {
                    object[] attrs = parameterInfo.GetCustomAttributes(typeof(ParamArrayAttribute), false);
                    if (attrs != null && attrs.Length > 0)
                    {
                        toolTipText.Append("params ");
                    }
                }

                toolTipText.Append(RuleDecompiler.DecompileType(paramType));
                toolTipText.Append(" ");
            }
            toolTipText.Append(parameterInfo.Name);
        }
コード例 #2
0
        private void ShowToolTip(int charIndex, string prefix)
        {
            Point positionFromCharIndex = this.GetPositionFromCharIndex(charIndex - 1);

            positionFromCharIndex.Y += ((int)Math.Ceiling((double)this.Font.GetHeight())) + 2;
            positionFromCharIndex.X -= 6;
            AutoCompletionEventArgs e = new AutoCompletionEventArgs {
                Prefix = prefix
            };

            if (this.PopulateToolTipList != null)
            {
                this.PopulateToolTipList(this, e);
                if (e.AutoCompleteValues != null)
                {
                    StringBuilder toolTipText = new StringBuilder();
                    bool          flag        = true;
                    foreach (MemberInfo info in e.AutoCompleteValues)
                    {
                        if (flag)
                        {
                            flag = false;
                        }
                        else
                        {
                            toolTipText.Append("\n");
                        }
                        ParameterInfo[] parameters = null;
                        MethodInfo      info2      = info as MethodInfo;
                        if (info2 != null)
                        {
                            toolTipText.Append(RuleDecompiler.DecompileType(info2.ReturnType));
                            toolTipText.Append(" ");
                            toolTipText.Append(info2.Name);
                            toolTipText.Append("(");
                            parameters = info2.GetParameters();
                        }
                        else
                        {
                            ConstructorInfo info3 = (ConstructorInfo)info;
                            toolTipText.Append(RuleDecompiler.DecompileType(info3.DeclaringType));
                            toolTipText.Append("(");
                            parameters = info3.GetParameters();
                        }
                        if ((parameters != null) && (parameters.Length > 0))
                        {
                            int num = parameters.Length - 1;
                            AppendParameterInfo(toolTipText, parameters[0], 0 == num);
                            for (int i = 1; i < parameters.Length; i++)
                            {
                                toolTipText.Append(", ");
                                AppendParameterInfo(toolTipText, parameters[i], i == num);
                            }
                        }
                        toolTipText.Append(")");
                    }
                    this.toolTip.Show(toolTipText.ToString(), this, positionFromCharIndex);
                }
            }
        }
コード例 #3
0
        private void ShowToolTip(int charIndex, string prefix)
        {
            Point clientPoint = this.GetPositionFromCharIndex(charIndex - 1);

            clientPoint.Y += (int)Math.Ceiling(this.Font.GetHeight()) + 2;
            clientPoint.X -= 6;

            AutoCompletionEventArgs autoCompletionEventArgs = new AutoCompletionEventArgs
            {
                Prefix = prefix
            };

            if (this.PopulateToolTipList != null)
            {
                this.PopulateToolTipList(this, autoCompletionEventArgs);

                if (autoCompletionEventArgs.AutoCompleteValues != null)
                {
                    StringBuilder toolTipText = new StringBuilder();
                    bool          firstMethod = true;
                    foreach (MemberInfo memberInfo in autoCompletionEventArgs.AutoCompleteValues)
                    {
                        if (firstMethod)
                        {
                            firstMethod = false;
                        }
                        else
                        {
                            toolTipText.Append("\n");
                        }

                        ParameterInfo[] parameters = null;

                        if (memberInfo is MethodInfo methodInfo)
                        {
                            toolTipText.Append(RuleDecompiler.DecompileType(methodInfo.ReturnType));
                            toolTipText.Append(" ");
                            toolTipText.Append(methodInfo.Name);
                            toolTipText.Append("(");

                            parameters = methodInfo.GetParameters();
                        }
                        else
                        {
                            // Must be constructor... if not, the best thing to do is let it throw "invalid cast".
                            ConstructorInfo ctorInfo = (ConstructorInfo)memberInfo;

                            toolTipText.Append(RuleDecompiler.DecompileType(ctorInfo.DeclaringType));
                            toolTipText.Append("(");

                            parameters = ctorInfo.GetParameters();
                        }


                        if (parameters != null && parameters.Length > 0)
                        {
                            int lastParamIndex = parameters.Length - 1;

                            // Append the first parameter
                            AppendParameterInfo(toolTipText, parameters[0], 0 == lastParamIndex);
                            for (int i = 1; i < parameters.Length; ++i)
                            {
                                toolTipText.Append(", ");
                                AppendParameterInfo(toolTipText, parameters[i], i == lastParamIndex);
                            }
                        }

                        toolTipText.Append(")");
                    }
                    this.toolTip.Show(toolTipText.ToString(), this, clientPoint);
                }
            }
        }