Created
April 4, 2017 19:57
-
-
Save lggomez/80f6df7c53d18192561b3d2a484ba78e to your computer and use it in GitHub Desktop.
Get non System.Object methods from a given type parameter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private static List<MethodInfo> GetTypeMethods<T>() | |
| { | |
| List<MethodInfo> interfaceMethods = new List<MethodInfo>(); | |
| var targetType = typeof(T); | |
| foreach (MethodInfo method in targetType.GetMethods() ) | |
| { | |
| if (!method.IsSpecialName && | |
| !new List<string> { "tostring", "gethashcode", "equals", "gettype", "finalize", "memberwiseclone" }.Any(method.Name.ToLowerInvariant().Contains)) | |
| { | |
| interfaceMethods.Add(method); | |
| } | |
| } | |
| return interfaceMethods.GroupBy(_ => _.Name).Select(_ => _.First()).ToList(); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment