Ejemplo n.º 1
0
        // When a link is clicked to this, the linkModifier is the
        // type or the assembly
        public void ShowTarget(Object linkModifier)
        {
            if (linkModifier == null)
            {
                return;
            }

            Assembly   assy;
            Type       type       = null;
            MemberInfo memberInfo = null;

            if (linkModifier is Assembly)
            {
                assy = (Assembly)linkModifier;
            }
            else if (linkModifier is Type)
            {
                type = (Type)linkModifier;
                assy = type.Assembly;
            }
            else             // MemberInfo
            {
                memberInfo = (MemberInfo)linkModifier;
                type       = memberInfo.DeclaringType;
                assy       = type.Assembly;
            }

            AssemblySupport.SelectAssyTab();

            AssemblyTreeNode node =
                AssemblySupport.FindAssemblyTreeNode(assy);

            if (node == null)
            {
                throw new Exception("Bug: assembly not found for type: " + type);
            }

            if (type != null)
            {
                TypeTreeNode typeNode = node.GetTypeNode(type);
                if (typeNode == null)
                {
                    throw new Exception("Bug: typeNode not found for type: "
                                        + type);
                }

                if (memberInfo != null)
                {
                    MemberTreeNode memberNode =
                        typeNode.FindMemberNode(memberInfo,
                                                !TypeTreeNode.FIND_NESTED);
                    if (memberNode != null)
                    {
                        memberNode.PointToNode();
                    }
                    else
                    {
                        throw new Exception("Bug: member not found for type: "
                                            + type + " mem: " + memberInfo);
                    }
                }
                else
                {
                    typeNode.PointToNode();
                }
            }
            else
            {
                node.PointToNode();
            }
        }