Ejemplo n.º 1
0
        internal bool MemberShouldBeVisible(MemberInfo member)
        {
            if (ShowNonPublic)
            {
                return(true);
            }

            AccessModifiers effectiveAccess = NetMemberBrowserInfo.GetMemberAccess(member);

            switch (effectiveAccess)
            {
            case AccessModifiers.Public:
            case AccessModifiers.Protected:
            case AccessModifiers.ProtectedInternal:
                return(true);

            case AccessModifiers.Internal:
            case AccessModifiers.Private:
            case AccessModifiers.Unknown:
                return(false);

            default:
                Debug.Fail("Unexpected AccessModifiers value: " + effectiveAccess.ToString());
                return(false);
            }
        }
Ejemplo n.º 2
0
        public override int CompareTo(object obj)
        {
            if (!(obj is NetMemberBrowserInfo))
            {
                throw new ArgumentException("Object must be of type '" + GetType().FullName + "'.", "obj");
            }

            NetMemberBrowserInfo other = (NetMemberBrowserInfo)obj;

            if (other == this)
            {
                return(0);
            }

            switch (Settings.MemberOrder)
            {
            case MemberOrder.Alphabetical:
                // Compare names
                int result1 = CompareMemberNames(Settings, m_memberInfo, other.m_memberInfo);
                if (result1 != 0)
                {
                    return(result1);
                }

                // Compare member types
                return(GetMemberTypePriority(m_memberInfo).CompareTo(
                           GetMemberTypePriority(other.m_memberInfo)));

            case MemberOrder.MemberType:
                // Compare member types
                int result2 = GetMemberTypePriority(m_memberInfo).CompareTo(
                    GetMemberTypePriority(other.m_memberInfo));
                if (result2 != 0)
                {
                    return(result2);
                }

                // Compare names
                return(CompareMemberNames(Settings, m_memberInfo, other.m_memberInfo));

            case MemberOrder.MemberAccess:
                // Compare member access
                int result3 = GetMemberAccess(m_memberInfo).CompareTo(
                    GetMemberAccess(other.m_memberInfo));
                if (result3 != 0)
                {
                    return(result3);
                }

                // Compare names
                return(CompareMemberNames(Settings, m_memberInfo, other.m_memberInfo));

            default:
                throw new ApplicationException("Unsupported MemberOrder enum value: '"
                                               + Settings.MemberOrder.ToString() + "'.");
            }
        }
Ejemplo n.º 3
0
        internal RemoteMemberBrowserInfo(NetMemberBrowserInfo wrapped, RemoteTypeBrowserInfo type, string nodeText)
        {
            Debug.Assert(wrapped != null && type != null && nodeText != null,
                         "wrapped != null && type != null && nodeText != null");

            m_wrapped  = wrapped;
            m_type     = type;
            m_nodeText = nodeText;
        }
Ejemplo n.º 4
0
        public override bool Equals(object obj)
        {
            NetMemberBrowserInfo other = obj as NetMemberBrowserInfo;

            if (other == null)
            {
                return(false);
            }

            // The other object may be a RemoteMemberBrowserInfo or just a NetMemberBrowserInfo.

            RemoteMemberBrowserInfo otherRemote = other as RemoteMemberBrowserInfo;

            if (otherRemote == null)
            {
                return(object.Equals(Wrapped, other));
            }
            else
            {
                return(object.Equals(Wrapped, otherRemote.Wrapped));
            }
        }
Ejemplo n.º 5
0
 private void CreateWrappedObject()
 {
     m_wrapped = m_type.GetMember(m_nodeText);
     Debug.Assert(m_wrapped != null, "m_wrapped != null");
 }
Ejemplo n.º 6
0
        private SortedList GetMembers()
        {
            const BindingFlags flags = BindingFlags.Public | BindingFlags.NonPublic
                                       | BindingFlags.Static | BindingFlags.Instance | BindingFlags.DeclaredOnly;

            try
            {
                MemberInfo[] memberInfos = m_type.GetMembers(flags);
                SortedList   members     = new SortedList();

                foreach (MemberInfo memberInfo in memberInfos)
                {
                    if (memberInfo.MemberType == MemberTypes.NestedType)
                    {
                        continue;                         // Nested types are shown separately
                    }
                    if (!Settings.MemberShouldBeVisible(memberInfo))
                    {
                        continue;                         // The user has chosen not to see members with this visibility.
                    }
                    string memberNodeText;

                    switch (memberInfo.MemberType)
                    {
                    case MemberTypes.Constructor:
                        // Constructor - use the type name as the member name
                        memberNodeText = m_type.Name + "(" + GetParameterTypes((MethodBase)memberInfo) + ")";
                        break;

                    case MemberTypes.Method:
                        // Don't show private interface implementations - they are shown under the interface
                        if (memberInfo.Name.IndexOf(Type.Delimiter) != -1)
                        {
                            continue;
                        }

                        // Don't show "special" methods - get/set for properties, add/remove for events, etc.,
                        // except for operators.
                        if ((((MethodInfo)memberInfo).Attributes & MethodAttributes.SpecialName) == MethodAttributes.SpecialName)
                        {
                            if (memberInfo.Name.StartsWith("op_"))
                            {
                                memberNodeText = NetMemberBrowserInfo.GetOperatorName(Settings, memberInfo.Name)
                                                 + "(" + GetParameterTypes((MethodBase)memberInfo) + ")";
                            }
                            else
                            {
                                continue;
                            }
                        }
                        else
                        {
                            memberNodeText = memberInfo.Name + "(" + GetParameterTypes((MethodBase)memberInfo) + ")";
                        }
                        break;

                    case MemberTypes.Field:
                        // Don't show "special" fields - value__ for enums, etc.
                        if (((FieldInfo)memberInfo).IsSpecialName)
                        {
                            continue;
                        }

                        // Don't show the private EventHandler fields for events. These fields have the
                        // same name as the event.
                        if (m_type.GetEvent(memberInfo.Name, flags) != null)
                        {
                            continue;
                        }

                        memberNodeText = memberInfo.Name;
                        break;

                    case MemberTypes.Property:
                        // Even if we don't have permission to access a property, the permission
                        // attributes only apply to the accessors - properties are "special" in
                        // this sense. Check for this now and if we cannot get any accessors then
                        // don't display the property at all.
                        if (((PropertyInfo)memberInfo).GetAccessors(true).Length == 0)
                        {
                            continue;
                        }

                        // Don't show private interface implementations - they are shown under the interface
                        if (memberInfo.Name.IndexOf(Type.Delimiter) != -1)
                        {
                            continue;
                        }

                        memberNodeText = memberInfo.Name;
                        break;

                    default:
                        // Don't show private interface implementations - they are shown under the interface
                        if (memberInfo.Name.IndexOf(Type.Delimiter) != -1)
                        {
                            continue;
                        }

                        memberNodeText = memberInfo.Name;
                        break;
                    }

                    members.Add(new NetMemberBrowserInfo(this, memberInfo, memberNodeText), memberNodeText);
                }

                return(members);
            }
            catch (System.Exception ex)
            {
                throw new ApplicationException("Failed to get the members of type '" + m_type.FullName + "'.", ex);
            }
        }