Created
August 2, 2015 08:41
-
-
Save RyuaNerin/497ccf5f4de2c1934e7e to your computer and use it in GitHub Desktop.
MethodInfo 가 특정 delegate 랑 같은 형식인지 확인해주는거. Linq 가 필요하다
This file contains 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 bool IsMethodCompatibleWithDelegate<T>(MethodInfo method) where T : class | |
{ | |
return IsMethodCompatibleWithDelegate(method, typeof(T)); | |
} | |
public static bool IsMethodCompatibleWithDelegate(MethodInfo method, Type delegateType) | |
{ | |
MethodInfo invoke = delegateType.GetMethod("Invoke"); | |
return invoke.ReturnType == method.ReturnType && | |
invoke.GetParameters().Select(x => x.ParameterType) | |
.SequenceEqual(method.GetParameters().Select(x => x.ParameterType)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment