示例#1
0
 /// <summary>
 /// Get a delegate for an instance method directly declared by <paramref name="instance"/>'s type.
 /// </summary>
 /// <param name="instance">The instance for which the method is defined.</param>
 /// <param name="method">The name of the method (case sensitive).</param>
 /// <returns>
 /// A delegate or <see langword="null"/> when <paramref name="instance"/> or <paramref name="method"/>
 /// is <see langword="null"/> or when the method cannot be found.
 /// </returns>
 public static TDelegate?GetDeclaredDelegate <TDelegate, TInstance>(TInstance instance,
                                                                    string method) where TDelegate : Delegate
 => AccessTools3.GetDeclaredDelegate <TDelegate, TInstance>(instance, method);
示例#2
0
 /// <summary>
 /// Get a delegate for an instance method named <paramref name="method"/>, directly declared by <paramref name="instance"/>'s type.
 /// 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="instance">The instance for which the method is defined.</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="instance"/> or <paramref name="method"/>
 /// is <see langword="null"/> or when the method cannot be found.
 /// </returns>
 public static TDelegate?GetDeclaredDelegate <TDelegate, TInstance>(TInstance instance,
                                                                    string method,
                                                                    Type[]?parameters,
                                                                    Type[]?generics = null) where TDelegate : Delegate
 => AccessTools3.GetDeclaredDelegate <TDelegate, TInstance>(instance, method, parameters, generics);
示例#3
0
 /// <summary>
 /// Get a delegate for a method named <paramref name="method"/>, directly declared by <paramref name="type"/>.
 /// </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?GetDeclaredDelegate <TDelegate>(Type type, string method) where TDelegate : Delegate
 => AccessTools3.GetDeclaredDelegate <TDelegate>(type, method);