/// <summary> /// The get events ex. /// </summary> /// <param name="type">The type.</param> /// <param name="flattenHierarchy">The flatten Hierarchy.</param> /// <param name="allowStaticMembers">The allow Static Members.</param> /// <returns>EventInfo[][].</returns> /// <exception cref="System.ArgumentNullException">The <paramref name="type" /> is <c>null</c>.</exception> public static EventInfo[] GetEventsEx(this Type type, bool flattenHierarchy = true, bool allowStaticMembers = false) { Argument.IsNotNull("type", type); var bindingFlags = BindingFlagsHelper.GetFinalBindingFlags(flattenHierarchy, allowStaticMembers); // Explicitly use Catel.Reflection.TypeInfoExtensions, see https://github.com/Catel/Catel/issues/1617 //return Catel.Reflection.TypeInfoExtensions.GetEvents(type.GetTypeInfo(), bindingFlags); return(type.GetEvents(bindingFlags)); }
/// <summary> /// The get constructor ex. /// </summary> /// <param name="type">The type.</param> /// <param name="types">The types.</param> /// <returns>ConstructorInfo.</returns> /// <exception cref="System.ArgumentNullException">The <paramref name="type" /> is <c>null</c>.</exception> /// <exception cref="System.ArgumentNullException">The <paramref name="types" /> is <c>null</c>.</exception> public static ConstructorInfo GetConstructorEx(this Type type, Type[] types) { Argument.IsNotNull("type", type); Argument.IsNotNull("types", types); #if UAP_DEFAULT return(type.GetTypeInfo().GetConstructor(types, BindingFlagsHelper.GetFinalBindingFlags(false, false))); #else return(type.GetConstructor(types)); #endif }
/// <summary> /// The get events ex. /// </summary> /// <param name="type">The type.</param> /// <param name="flattenHierarchy">The flatten Hierarchy.</param> /// <param name="allowStaticMembers">The allow Static Members.</param> /// <returns>EventInfo[][].</returns> /// <exception cref="System.ArgumentNullException">The <paramref name="type" /> is <c>null</c>.</exception> public static EventInfo[] GetEventsEx(this Type type, bool flattenHierarchy = true, bool allowStaticMembers = false) { Argument.IsNotNull("type", type); BindingFlags bindingFlags = BindingFlagsHelper.GetFinalBindingFlags(flattenHierarchy, allowStaticMembers); #if ENABLE_CACHE var cacheKey = new ReflectionCacheKey(type, ReflectionTypes.Event, bindingFlags); return(_eventsCache.GetFromCacheOrFetch(cacheKey, () => type.GetTypeInfo().GetEvents(bindingFlags))); #else return(type.GetTypeInfo().GetEvents(bindingFlags)); #endif }
/// <summary> /// The get constructor ex. /// </summary> /// <param name="type">The type.</param> /// <param name="types">The types.</param> /// <returns>ConstructorInfo.</returns> /// <exception cref="System.ArgumentNullException">The <paramref name="type" /> is <c>null</c>.</exception> /// <exception cref="System.ArgumentNullException">The <paramref name="types" /> is <c>null</c>.</exception> public static ConstructorInfo GetConstructorEx(this Type type, Type[] types) { Argument.IsNotNull("type", type); Argument.IsNotNull("types", types); #if ENABLE_CACHE var cacheKey = new ReflectionCacheKey(type, ReflectionTypes.Constructor, BindingFlags.Default, types); #if NETFX_CORE || PCL return(_constructorCache.GetFromCacheOrFetch(cacheKey, () => type.GetTypeInfo().GetConstructor(types, BindingFlagsHelper.GetFinalBindingFlags(false, false)))); #else return(_constructorCache.GetFromCacheOrFetch(cacheKey, () => type.GetConstructor(types))); #endif #else #if NETFX_CORE || PCL return(type.GetTypeInfo().GetConstructor(types, BindingFlagsHelper.GetFinalBindingFlags(false, false))); #else return(type.GetConstructor(types)); #endif #endif }
/// <summary> /// The get event ex. /// </summary> /// <param name="type">The type.</param> /// <param name="name">The name.</param> /// <param name="flattenHierarchy">The flatten Hierarchy.</param> /// <param name="allowStaticMembers">The allow Static Members.</param> /// <returns>EventInfo.</returns> /// <exception cref="System.ArgumentNullException">The <paramref name="type" /> is <c>null</c>.</exception> /// <exception cref="System.ArgumentException">The <paramref name="name" /> is <c>null</c> or whitespace.</exception> public static EventInfo GetEventEx(this Type type, string name, bool flattenHierarchy = true, bool allowStaticMembers = false) { return(GetEventEx(type, name, BindingFlagsHelper.GetFinalBindingFlags(flattenHierarchy, allowStaticMembers))); }
/// <summary> /// The get properties ex. /// </summary> /// <param name="type">The type.</param> /// <param name="flattenHierarchy">The flatten hierarchy.</param> /// <param name="allowStaticMembers">The allow static members.</param> /// <returns>PropertyInfo[][].</returns> /// <exception cref="System.ArgumentNullException">The <paramref name="type" /> is <c>null</c>.</exception> public static PropertyInfo[] GetPropertiesEx(this Type type, bool flattenHierarchy = true, bool allowStaticMembers = false) { return(GetPropertiesEx(type, BindingFlagsHelper.GetFinalBindingFlags(flattenHierarchy, allowStaticMembers))); }
/// <summary> /// The get property ex. /// </summary> /// <param name="type"> /// The type. /// </param> /// <param name="name"> /// The name. /// </param> /// <param name="flattenHierarchy"> /// The flatten hierarchy. /// </param> /// <param name="allowStaticMembers"> /// The allow static members. /// </param> /// <returns> /// </returns> /// <exception cref="System.ArgumentNullException"> /// The <paramref name="type"/> is <c>null</c>. /// </exception> /// <exception cref="System.ArgumentException"> /// The <paramref name="name"/> is <c>null</c> or whitespace. /// </exception> public static PropertyInfo GetPropertyEx(this Type type, string name, bool flattenHierarchy = true, bool allowStaticMembers = false) { BindingFlags bindingFlags = BindingFlagsHelper.GetFinalBindingFlags(flattenHierarchy, allowStaticMembers); return(GetPropertyEx(type, name, bindingFlags)); }