Catel.Reflection.TypeInfoExtensions.GetMethods C# (CSharp) Method

GetMethods() public static method

Gets the methods.
The is null.
public static GetMethods ( this typeInfo, BindingFlags bindingFlags ) : System.Reflection.MethodInfo[]
typeInfo this The .
bindingFlags BindingFlags The binding flags.
return System.Reflection.MethodInfo[]
        public static MethodInfo[] GetMethods(this TypeInfo typeInfo, BindingFlags bindingFlags)
        {
            Argument.IsNotNull("typeInfo", typeInfo);

            var flattenHierarchy = ShouldFlattenHierarchy(bindingFlags);
            var source = flattenHierarchy ? typeInfo.AsType().GetRuntimeMethods().ToList() : typeInfo.DeclaredMethods.ToList();

            var includeStatics = Enum<BindingFlags>.Flags.IsFlagSet(bindingFlags, BindingFlags.Static);

            // TODO: This is a fix because static members are not included in FlattenHierarcy, remove when this is fixed in WinRT
            if (flattenHierarchy)
            {
                var baseType = typeInfo.BaseType;
                if ((baseType != null) && (baseType != typeof(object)))
                {
                    source.AddRange(from member in GetMethods(baseType.GetTypeInfo(), bindingFlags)
                                    where member.IsStatic
                                    select member);
                }
            }

            if (!includeStatics)
            {
                source = (from x in source
                          where !x.IsStatic
                          select x).ToList();
            }

            return (from x in source
                    select x).ToArray();
        }