private T[] GetMembersHelper <T>(BindingFlags bindingAttr, MemberSignature memberSignature, ref T[] members)
            where T : MemberInfo
        {
            List <T> memberCandidates = new List <T>();

            foreach (T memberInfo in this.GetMembersHelper <T>(bindingAttr, ref members, true))
            {
                MemberSignature candididateMemberSignature = new MemberSignature(memberInfo);
                if (candididateMemberSignature.FilterSignature(memberSignature))
                {
                    memberCandidates.Add(memberInfo);
                }
            }
            return(memberCandidates.ToArray());
        }
        //private MemberInfo[] GetBaseMembers(Type type, Type baseType, BindingFlags bindingAttr)
        //{
        //    MemberInfo[] members = null;
        //    if (type == typeof(PropertyInfo))
        //    {
        //        members = baseType.GetProperties(bindingAttr);
        //    }
        //    else if (type == typeof(EventInfo))
        //    {
        //        members = baseType.GetEvents(bindingAttr);
        //    }
        //    else if (type == typeof(ConstructorInfo))
        //    {
        //        members = baseType.GetConstructors(bindingAttr);
        //    }
        //    else if (type == typeof(MethodInfo))
        //    {
        //        members = baseType.GetMethods(bindingAttr);
        //    }
        //    else if (type == typeof(FieldInfo))
        //    {
        //        members = baseType.GetFields(bindingAttr);
        //    }
        //    else if (type == typeof(Type))
        //    {
        //        members = baseType.GetNestedTypes(bindingAttr);
        //    }

        //    return members;
        //}

        // generic method that implements all GetXXX methods
        private T GetMemberHelper <T>(BindingFlags bindingAttr, MemberSignature memberSignature, ref T[] members)
            where T : MemberInfo
        {
            if (members != null)
            {
                // search the local type
                foreach (T memberInfo in members)
                {
                    MemberSignature candididateMemberSignature = new MemberSignature(memberInfo);
                    if (candididateMemberSignature.FilterSignature(memberSignature) && FilterMember(memberInfo, bindingAttr))
                    {
                        return(memberInfo);
                    }
                }
            }

            return(null);
        }