Exemplo n.º 1
0
 /// <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);
Exemplo n.º 2
0
 /// <summary>
 /// Get a delegate for a method named <paramref name="method"/>, directly declared by <paramref name="type"/>,
 /// 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?GetDeclaredDelegateObjectInstance <TDelegate>(Type type, string method) where TDelegate : Delegate
 => AccessTools3.GetDeclaredDelegateObjectInstance <TDelegate>(type, method);
Exemplo n.º 3
0
 public static TDelegate?GetDelegate <TDelegate>(ConstructorInfo?constructorInfo) where TDelegate : Delegate
 => AccessTools3.GetDelegate <TDelegate>(constructorInfo);
Exemplo n.º 4
0
 public static TDelegate?GetDeclaredConstructorDelegate <TDelegate>(Type type, Type[]?parameters = null) where TDelegate : Delegate
 => AccessTools3.GetDeclaredConstructorDelegate <TDelegate>(type, parameters);
Exemplo n.º 5
0
 /// <summary>Creates an instance field reference delegate for a private type</summary>
 /// <typeparam name="TField">The type of the field</typeparam>
 /// <param name="type">The class/type</param>
 /// <param name="fieldName">The name of the field</param>
 /// <returns>A read and writable <see cref="T:HarmonyLib.AccessTools.FieldRef`2" /> delegate</returns>
 public static FieldRef <object, TField>?FieldRefAccess <TField>(Type type, string fieldName)
 => AccessTools3.FieldRefAccess <TField>(type, fieldName);
Exemplo n.º 6
0
 /// <summary>
 /// Get a delegate for an instance method described by <paramref name="methodInfo"/> and bound to <paramref name="instance"/>.
 /// </summary>
 /// <param name="instance">The instance for which the method is defined.</param>
 /// <param name="methodInfo">The method's <see cref="MethodInfo"/>.</param>
 /// <returns>
 /// A delegate or <see langword="null"/> when <paramref name="instance"/> or <paramref name="methodInfo"/>
 /// is <see langword="null"/> or when the method cannot be found.
 /// </returns>
 public static TDelegate?GetDelegate <TDelegate>(object?instance, MethodInfo?methodInfo) where TDelegate : Delegate
 => AccessTools3.GetDelegate <TDelegate>(instance, methodInfo);
Exemplo n.º 7
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);
Exemplo n.º 8
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);
Exemplo n.º 9
0
 /// <summary>Get a delegate for a method described by <paramref name="methodInfo"/>.</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?GetDelegate <TDelegate>(MethodInfo?methodInfo) where TDelegate : Delegate
 => AccessTools3.GetDelegate <TDelegate>(methodInfo);
Exemplo n.º 10
0
 /// <summary>Creates a static field reference delegate</summary>
 /// <typeparam name="TField">The type of the field</typeparam>
 /// <param name="fieldInfo">The field</param>
 /// <returns>A read and writable <see cref="T:HarmonyLib.AccessTools.FieldRef`1" /> delegate</returns>
 public static FieldRef <TField>?StaticFieldRefAccess <TField>(FieldInfo?fieldInfo)
 => AccessTools3.StaticFieldRefAccess <TField>(fieldInfo);
Exemplo n.º 11
0
 /// <summary>
 /// Get a delegate for a method named <paramref name="method"/>, declared by <paramref name="type"/> or any of its base types.
 /// </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>
 /// <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?GetDelegate <TDelegate>(Type type, string method) where TDelegate : Delegate
 => AccessTools3.GetDelegate <TDelegate>(type, method);