Example #1
0
        /// <summary>
        ///
        /// </summary>
        /// <typeparam name="TDescriptor"></typeparam>
        /// <typeparam name="TCollection"></typeparam>
        /// <param name="declaringType"></param>
        /// <param name="inherit"></param>
        /// <param name="nonPublic"></param>
        /// <param name="attributeType"></param>
        /// <returns></returns>
        public static TCollection RetrieveMemberDescriptors <TDescriptor, TCollection>(Type declaringType, bool inherit, bool nonPublic, Type attributeType)
            where TDescriptor : MemberDescriptor
            where TCollection : ReadOnlyListCollection <TDescriptor>
        {
            var _descriptors = MethodMemberHelpers.RetrieveMembers(declaringType, nonPublic, attributeType, inherit)
                               .Select(meth => MemberDescriptor.Initializer.Initialize <TDescriptor>(meth));

            return(ReadOnlyListCollection <TDescriptor> .Initializer.Initialize <TCollection>(_descriptors));
        }
Example #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="instance"></param>
        /// <param name="inherit"></param>
        /// <param name="nonPublic"></param>
        /// <param name="attributeType"></param>
        /// <returns></returns>
        public static MethodInfo[] RetrieveMembers(object instance, bool nonPublic, Type attributeType, bool inherit)
        {
            if (null == instance)
            {
                throw new ArgumentNullException("instance");
            }

            return(MethodMemberHelpers.RetrieveMembers(instance.GetType(), nonPublic, attributeType, inherit));
        }