diff options
author | Jesse Plamondon-Willard <github@jplamondonw.com> | 2016-12-12 11:52:34 -0500 |
---|---|---|
committer | Jesse Plamondon-Willard <github@jplamondonw.com> | 2016-12-12 11:52:34 -0500 |
commit | 28e2695a19f7babf35d177367840a82b798beb55 (patch) | |
tree | 591b2badd77a7c9c0c36b8e09abdb6a323513307 /src/StardewModdingAPI/IReflectionHelper.cs | |
parent | aaf354761f18a18b0bcb81c9bd32819bb28deac9 (diff) | |
parent | a3376e2a6257c01c52a3c64c4f5f1f8de9a9c906 (diff) | |
download | SMAPI-28e2695a19f7babf35d177367840a82b798beb55.tar.gz SMAPI-28e2695a19f7babf35d177367840a82b798beb55.tar.bz2 SMAPI-28e2695a19f7babf35d177367840a82b798beb55.zip |
Merge branch 'develop' into stable
Diffstat (limited to 'src/StardewModdingAPI/IReflectionHelper.cs')
-rw-r--r-- | src/StardewModdingAPI/IReflectionHelper.cs | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/src/StardewModdingAPI/IReflectionHelper.cs b/src/StardewModdingAPI/IReflectionHelper.cs new file mode 100644 index 00000000..5d747eda --- /dev/null +++ b/src/StardewModdingAPI/IReflectionHelper.cs @@ -0,0 +1,53 @@ +using System; + +namespace StardewModdingAPI +{ + /// <summary>Simplifies access to private game code.</summary> + public interface IReflectionHelper + { + /********* + ** Public methods + *********/ + /// <summary>Get a private instance field.</summary> + /// <typeparam name="TValue">The field type.</typeparam> + /// <param name="obj">The object which has the field.</param> + /// <param name="name">The field name.</param> + /// <param name="required">Whether to throw an exception if the private field is not found.</param> + IPrivateField<TValue> GetPrivateField<TValue>(object obj, string name, bool required = true); + + /// <summary>Get a private static field.</summary> + /// <typeparam name="TValue">The field type.</typeparam> + /// <param name="type">The type which has the field.</param> + /// <param name="name">The field name.</param> + /// <param name="required">Whether to throw an exception if the private field is not found.</param> + IPrivateField<TValue> GetPrivateField<TValue>(Type type, string name, bool required = true); + + /// <summary>Get the value of a private instance field.</summary> + /// <typeparam name="TValue">The field type.</typeparam> + /// <param name="obj">The object which has the field.</param> + /// <param name="name">The field name.</param> + /// <param name="required">Whether to throw an exception if the private field is not found.</param> + /// <remarks>This is a shortcut for <see cref="GetPrivateField{TValue}(object,string,bool)"/> followed by <see cref="IPrivateField{TValue}.GetValue"/>.</remarks> + TValue GetPrivateValue<TValue>(object obj, string name, bool required = true); + + /// <summary>Get the value of a private static field.</summary> + /// <typeparam name="TValue">The field type.</typeparam> + /// <param name="type">The type which has the field.</param> + /// <param name="name">The field name.</param> + /// <param name="required">Whether to throw an exception if the private field is not found.</param> + /// <remarks>This is a shortcut for <see cref="GetPrivateField{TValue}(Type,string,bool)"/> followed by <see cref="IPrivateField{TValue}.GetValue"/>.</remarks> + TValue GetPrivateValue<TValue>(Type type, string name, bool required = true); + + /// <summary>Get a private instance method.</summary> + /// <param name="obj">The object which has the method.</param> + /// <param name="name">The field name.</param> + /// <param name="required">Whether to throw an exception if the private field is not found.</param> + IPrivateMethod GetPrivateMethod(object obj, string name, bool required = true); + + /// <summary>Get a private static method.</summary> + /// <param name="type">The type which has the method.</param> + /// <param name="name">The field name.</param> + /// <param name="required">Whether to throw an exception if the private field is not found.</param> + IPrivateMethod GetPrivateMethod(Type type, string name, bool required = true); + } +} |