コード例 #1
0
        // This could either be a MemberInfo, Type or a TypeLibrary,
        // and we point
        // to the correct node
        public void ShowTarget(Object linkModifier)
        {
            BrowserTreeNode resultNode = null;

            // A type library
            if (linkModifier is TypeLibrary)
            {
                resultNode = ComSupport.FindTypeLib(((TypeLibrary)linkModifier).Key);
            }
            else
            {
                Type type;
                if (linkModifier is Type)
                {
                    type = (Type)linkModifier;
                }
                else
                {
                    type = ((MemberInfo)linkModifier).DeclaringType;
                }
                // Get the typelib node
                TypeLibrary typeLib = TypeLibrary.GetTypeLib(type);
                if (typeLib == null)
                {
                    return;
                }
                // Find the type, this could be a class or an interface
                ComTypeLibTreeNode typeLibNode = (ComTypeLibTreeNode)ComSupport.FindTypeLib(typeLib.Key);
                String             typeName    = typeLib.GetMemberName(type);
                typeLibNode.ExpandNode();
                resultNode = SearchNode(typeLibNode, typeName);
                // Find the member (Type is also a MemberInfo)
                if (!(linkModifier is Type))
                {
                    MemberInfo      mi           = (MemberInfo)linkModifier;
                    ComTypeTreeNode typeTreeNode = (ComTypeTreeNode)resultNode;
                    resultNode = FindMember(typeLibNode, typeTreeNode, mi);
                }
            }
            // Point to the result
            if (resultNode != null)
            {
                ObjectBrowser.TabControl.SelectedTab = ComSupport.ComTabPage;
                resultNode.PointToNode();
            }
        }
コード例 #2
0
        // Adds the remembered type lib to the favorites part
        // of the type library tree
        internal static BrowserTreeNode AddTypeLib(TypeLibrary lib)
        {
            BrowserTreeNode findRoot;

            findRoot = _favTypeLibNode;
            if (findRoot == null)
            {
                return(null);
            }
            BrowserTreeNode typeLibNode = FindTypeLib(lib.Key, findRoot);

            if (typeLibNode == null)
            {
                typeLibNode = new ComTypeLibTreeNode(lib);
                // This might be called on the thread to restore open typelibs
                _comTree.Invoke(new BrowserTreeNode.AddLogicalInvoker(findRoot.AddLogicalNode),
                                new Object[] { typeLibNode });
            }
            return(typeLibNode);
        }
コード例 #3
0
        protected BrowserTreeNode FindMember(ComTypeLibTreeNode typeLibNode, ComTypeTreeNode typeTreeNode, MemberInfo mi)
        {
            // If we have a class, we need to look at all of
            // its implemented interfaces
            if (typeTreeNode.MemberInfo is ComClassInfo)
            {
                BrowserTreeNode resultNode = null;

                ComClassInfo classInfo = (ComClassInfo)typeTreeNode.MemberInfo;
                foreach (BasicInfo iface in classInfo.Interfaces)
                {
                    BrowserTreeNode ifaceNode =
                        SearchNode(typeLibNode, iface.Name);
                    String searchName = mi.Name;
                    // See if its a member name qualified by this
                    // interface name
                    if (mi.Name.StartsWith(iface.Name))
                    {
                        searchName = mi.Name.Substring(iface.Name.Length + 1);
                        if (mi is EventInfo &&
                            searchName.StartsWith("Event_"))
                        {
                            searchName = searchName.Substring(6);
                        }
                    }
                    resultNode = SearchNode(ifaceNode, searchName);
                    if (resultNode != null)
                    {
                        return(resultNode);
                    }
                }
                throw new Exception("(bug) - cant find member " + mi);
            }
            else
            {
                return(SearchNode(typeTreeNode, mi.Name));
            }
        }