private static void RedirectMethods( System.Type type, System.Type targetType, Dictionary <MethodInfo, Redirector> redirects, bool onCreated) { foreach (MethodInfo method in ((IEnumerable <MethodInfo>)type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)).Where <MethodInfo>((Func <MethodInfo, bool>)(method => { object[] customAttributes = method.GetCustomAttributes(typeof(RedirectMethodAttribute), false); if (customAttributes.Length != 1) { return(false); } return(((RedirectMethodAttribute)customAttributes[0]).OnCreated == onCreated); }))) { Debug.Log((object)("Redirecting " + targetType.Name + "#" + method.Name + "...")); Redirector redirector = RedirectionUtil.RedirectMethod(targetType, method, redirects, false); FieldInfo field = type.GetField(method.Name + "Redirector", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); if (field != null && field.FieldType == typeof(Redirector)) { Debug.Log((object)"Redirector field found!"); field.SetValue((object)null, (object)redirector); } } }
private static Redirector RedirectMethod( System.Type targetType, MethodInfo method, Dictionary <MethodInfo, Redirector> redirects, bool reverse = false) { Tuple <MethodInfo, Redirector> tuple = RedirectionUtil.RedirectMethod(targetType, method, reverse); redirects.Add(tuple.First, tuple.Second); return(tuple.Second); }
private static void RedirectReverse( System.Type type, System.Type targetType, Dictionary <MethodInfo, Redirector> redirects, bool onCreated) { foreach (MethodInfo method in ((IEnumerable <MethodInfo>)type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)).Where <MethodInfo>((Func <MethodInfo, bool>)(method => { object[] customAttributes = method.GetCustomAttributes(typeof(RedirectReverseAttribute), false); if (customAttributes.Length == 1) { return(((RedirectReverseAttribute)customAttributes[0]).OnCreated == onCreated); } return(false); }))) { Debug.Log((object)("Redirecting reverse " + targetType.Name + "#" + method.Name + "...")); RedirectionUtil.RedirectMethod(targetType, method, redirects, true); } }