/// <summary> /// Get a delegate for a method named <paramref name="method"/>, declared by <paramref name="type"/> or any of its base types, /// and then bind it to an instance type of <see cref="object"/>. /// </summary> /// <param name="type">The type where the method is declared.</param> /// <param name="method">The name of the method (case sensitive).</param> /// <returns> /// A delegate or <see langword="null"/> when <paramref name="type"/> or <paramref name="method"/> /// is <see langword="null"/> or when the method cannot be found. /// </returns> public static TDelegate?GetDelegateObjectInstance <TDelegate>(Type type, string method) where TDelegate : Delegate => AccessTools3.GetDelegateObjectInstance <TDelegate>(type, method);
/// <summary> /// Get a delegate for a method named <paramref name="method"/>, declared by <paramref name="type"/> or any of its base types, /// and then bind it to an instance type of <see cref="object"/>. /// Choose the overload with the given <paramref name="parameters"/> if not <see langword="null"/> /// and/or the generic arguments <paramref name="generics"/> if not <see langword="null"/>. /// </summary> /// <param name="type">The type from which to start searching for the method's definition.</param> /// <param name="method">The name of the method (case sensitive).</param> /// <param name="parameters">The method's parameter types (when not <see langword="null"/>).</param> /// <param name="generics">The generic arguments of the method (when not <see langword="null"/>).</param> /// <returns> /// A delegate or <see langword="null"/> when <paramref name="type"/> or <paramref name="method"/> /// is <see langword="null"/> or when the method cannot be found. /// </returns> public static TDelegate?GetDelegateObjectInstance <TDelegate>(Type type, string method, Type[]?parameters, Type[]?generics = null) where TDelegate : Delegate => AccessTools3.GetDelegateObjectInstance <TDelegate>(type, method, parameters, generics);
/// <summary>Get a delegate bound to the instance type <see cref="object"/>.</summary> /// <param name="methodInfo">The method's <see cref="MethodInfo"/>.</param> /// <returns>A delegate or <see langword="null"/> when <paramref name="methodInfo"/> is <see langword="null"/>.</returns> public static TDelegate?GetDelegateObjectInstance <TDelegate>(MethodInfo?methodInfo) where TDelegate : Delegate => AccessTools3.GetDelegateObjectInstance <TDelegate>(methodInfo);