Esempio n. 1
0
        /*
         * Create a LookupListItem from a type.
         */

        protected LookupListItem GetItem(Type type)
        {
            string typeName = CSharpFormattingTools.GetTypeSignature(type);
            string fullName = CSharpFormattingTools.GetTypeSignature(type, true);

            LookupListItem item = new LookupListItem();

            item.DisplayText = typeName;
            item.InsertText  = type.ContainsGenericParameters ?
                               CSharpFormattingTools.RemoveGenericSignature(typeName) :
                               typeName;

            // Classify the type - order is important here
            if (type.IsClass && type.IsSubclassOf(typeof(System.Delegate)))
            {
                item.Category    = QuickSharp.CodeAssist.Constants.DELEGATE;
                item.ToolTipText = String.Format("delegate {0}", fullName);
            }
            else if (type.IsEnum)
            {
                item.Category    = QuickSharp.CodeAssist.Constants.ENUM;
                item.ToolTipText = String.Format("enum {0}", fullName);
            }
            else if (type.IsValueType)
            {
                item.Category    = QuickSharp.CodeAssist.Constants.VALUETYPE;
                item.ToolTipText = String.Format("struct {0}", fullName);

                AddConstructors(type, item);
            }
            else if (type.IsInterface)
            {
                item.Category    = QuickSharp.CodeAssist.Constants.INTERFACE;
                item.ToolTipText = String.Format("interface {0}", fullName);
            }
            else
            {
                if (type.IsSealed)
                {
                    item.Category = QuickSharp.CodeAssist.Constants.CLASS_SEALED;
                }
                else
                {
                    item.Category = QuickSharp.CodeAssist.Constants.CLASS;
                }

                item.ToolTipText = String.Format("class {0}", fullName);

                AddConstructors(type, item);
            }

            return(item);
        }
        /*
         * Create a LookupListItem from a type.
         */

        protected LookupListItem GetItem(Type type)
        {
            string typeName = CSharpFormattingTools.GetTypeSignature(type);
            string fullName = CSharpFormattingTools.GetTypeSignature(type, true);

            LookupListItem item = new LookupListItem();

            item.DisplayText = typeName;
            item.InsertText  = type.ContainsGenericParameters ?
                               CSharpFormattingTools.RemoveGenericSignature(typeName) :
                               typeName;

            // Classify the type - order is important here
            if (type.IsClass && type.IsSubclassOf(typeof(System.Delegate)))
            {
                item.Category    = QuickSharp.CodeAssist.Constants.DELEGATE;
                item.ToolTipText = String.Format("delegate {0}", fullName);
            }
            else if (type.IsEnum)
            {
                item.Category    = QuickSharp.CodeAssist.Constants.ENUM;
                item.ToolTipText = String.Format("enum {0}", fullName);
            }
            else if (type.IsValueType)
            {
                item.Category    = QuickSharp.CodeAssist.Constants.VALUETYPE;
                item.ToolTipText = String.Format("struct {0}", fullName);
            }
            else if (type.IsInterface)
            {
                item.Category    = QuickSharp.CodeAssist.Constants.INTERFACE;
                item.ToolTipText = String.Format("interface {0}", fullName);
            }
            else
            {
                if (type.IsSealed)
                {
                    item.Category = QuickSharp.CodeAssist.Constants.CLASS_SEALED;
                }
                else
                {
                    item.Category = QuickSharp.CodeAssist.Constants.CLASS;
                }

                item.ToolTipText = String.Format("class {0}", fullName);

                BindingFlags bindingAttr =
                    BindingFlags.Public |
                    BindingFlags.FlattenHierarchy |
                    BindingFlags.Instance;

                ConstructorInfo[] cia = type.GetConstructors(bindingAttr);

                foreach (ConstructorInfo ci in cia)
                {
                    LookupMenuItem lmi = new LookupMenuItem();
                    lmi.DisplayText = JScriptFormattingTools.
                                      GetConstructorSignature(ci, type);
                    lmi.InsertText = JScriptFormattingTools.
                                     GetMinimalConstructorSignature(ci, type);

                    item.MenuItems.Add(lmi);
                }
            }

            return(item);
        }