From df7d41fc37521ecfe039e9661cf288c933cb2bdc Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sun, 11 Dec 2016 21:03:57 -0500 Subject: move interfaces into root (#185) --- .../Framework/Reflection/PrivateField.cs | 1 - .../Framework/Reflection/PrivateMethod.cs | 1 - .../Framework/Reflection/ReflectionHelper.cs | 1 - src/StardewModdingAPI/IModHelper.cs | 4 +- src/StardewModdingAPI/IPrivateField.cs | 26 +++++++++++ src/StardewModdingAPI/IPrivateMethod.cs | 27 +++++++++++ src/StardewModdingAPI/IReflectionHelper.cs | 53 ++++++++++++++++++++++ src/StardewModdingAPI/ModHelper.cs | 1 - src/StardewModdingAPI/Reflection/IPrivateField.cs | 26 ----------- src/StardewModdingAPI/Reflection/IPrivateMethod.cs | 27 ----------- .../Reflection/IReflectionHelper.cs | 53 ---------------------- src/StardewModdingAPI/StardewModdingAPI.csproj | 6 +-- 12 files changed, 110 insertions(+), 116 deletions(-) create mode 100644 src/StardewModdingAPI/IPrivateField.cs create mode 100644 src/StardewModdingAPI/IPrivateMethod.cs create mode 100644 src/StardewModdingAPI/IReflectionHelper.cs delete mode 100644 src/StardewModdingAPI/Reflection/IPrivateField.cs delete mode 100644 src/StardewModdingAPI/Reflection/IPrivateMethod.cs delete mode 100644 src/StardewModdingAPI/Reflection/IReflectionHelper.cs (limited to 'src') diff --git a/src/StardewModdingAPI/Framework/Reflection/PrivateField.cs b/src/StardewModdingAPI/Framework/Reflection/PrivateField.cs index 6e7e3382..0bf45969 100644 --- a/src/StardewModdingAPI/Framework/Reflection/PrivateField.cs +++ b/src/StardewModdingAPI/Framework/Reflection/PrivateField.cs @@ -1,6 +1,5 @@ using System; using System.Reflection; -using StardewModdingAPI.Reflection; namespace StardewModdingAPI.Framework.Reflection { diff --git a/src/StardewModdingAPI/Framework/Reflection/PrivateMethod.cs b/src/StardewModdingAPI/Framework/Reflection/PrivateMethod.cs index 5b882eed..ba2374f4 100644 --- a/src/StardewModdingAPI/Framework/Reflection/PrivateMethod.cs +++ b/src/StardewModdingAPI/Framework/Reflection/PrivateMethod.cs @@ -1,6 +1,5 @@ using System; using System.Reflection; -using StardewModdingAPI.Reflection; namespace StardewModdingAPI.Framework.Reflection { diff --git a/src/StardewModdingAPI/Framework/Reflection/ReflectionHelper.cs b/src/StardewModdingAPI/Framework/Reflection/ReflectionHelper.cs index fd916bbe..38b4e357 100644 --- a/src/StardewModdingAPI/Framework/Reflection/ReflectionHelper.cs +++ b/src/StardewModdingAPI/Framework/Reflection/ReflectionHelper.cs @@ -2,7 +2,6 @@ using System; using System.Linq; using System.Reflection; using System.Runtime.Caching; -using StardewModdingAPI.Reflection; namespace StardewModdingAPI.Framework.Reflection { diff --git a/src/StardewModdingAPI/IModHelper.cs b/src/StardewModdingAPI/IModHelper.cs index 709c8692..183b3b2b 100644 --- a/src/StardewModdingAPI/IModHelper.cs +++ b/src/StardewModdingAPI/IModHelper.cs @@ -1,6 +1,4 @@ -using StardewModdingAPI.Reflection; - -namespace StardewModdingAPI +namespace StardewModdingAPI { /// Provides simplified APIs for writing mods. public interface IModHelper diff --git a/src/StardewModdingAPI/IPrivateField.cs b/src/StardewModdingAPI/IPrivateField.cs new file mode 100644 index 00000000..3e681c12 --- /dev/null +++ b/src/StardewModdingAPI/IPrivateField.cs @@ -0,0 +1,26 @@ +using System.Reflection; + +namespace StardewModdingAPI +{ + /// A private field obtained through reflection. + /// The field value type. + public interface IPrivateField + { + /********* + ** Accessors + *********/ + /// The reflection metadata. + FieldInfo FieldInfo { get; } + + + /********* + ** Public methods + *********/ + /// Get the field value. + TValue GetValue(); + + /// Set the field value. + //// The value to set. + void SetValue(TValue value); + } +} \ No newline at end of file diff --git a/src/StardewModdingAPI/IPrivateMethod.cs b/src/StardewModdingAPI/IPrivateMethod.cs new file mode 100644 index 00000000..67fc8b3c --- /dev/null +++ b/src/StardewModdingAPI/IPrivateMethod.cs @@ -0,0 +1,27 @@ +using System.Reflection; + +namespace StardewModdingAPI +{ + /// A private method obtained through reflection. + public interface IPrivateMethod + { + /********* + ** Accessors + *********/ + /// The reflection metadata. + MethodInfo MethodInfo { get; } + + + /********* + ** Public methods + *********/ + /// Invoke the method. + /// The return type. + /// The method arguments to pass in. + TValue Invoke(params object[] arguments); + + /// Invoke the method. + /// The method arguments to pass in. + void Invoke(params object[] arguments); + } +} \ No newline at end of file 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 +{ + /// Simplifies access to private game code. + public interface IReflectionHelper + { + /********* + ** Public methods + *********/ + /// Get a private instance field. + /// The field type. + /// The object which has the field. + /// The field name. + /// Whether to throw an exception if the private field is not found. + IPrivateField GetPrivateField(object obj, string name, bool required = true); + + /// Get a private static field. + /// The field type. + /// The type which has the field. + /// The field name. + /// Whether to throw an exception if the private field is not found. + IPrivateField GetPrivateField(Type type, string name, bool required = true); + + /// Get the value of a private instance field. + /// The field type. + /// The object which has the field. + /// The field name. + /// Whether to throw an exception if the private field is not found. + /// This is a shortcut for followed by . + TValue GetPrivateValue(object obj, string name, bool required = true); + + /// Get the value of a private static field. + /// The field type. + /// The type which has the field. + /// The field name. + /// Whether to throw an exception if the private field is not found. + /// This is a shortcut for followed by . + TValue GetPrivateValue(Type type, string name, bool required = true); + + /// Get a private instance method. + /// The object which has the method. + /// The field name. + /// Whether to throw an exception if the private field is not found. + IPrivateMethod GetPrivateMethod(object obj, string name, bool required = true); + + /// Get a private static method. + /// The type which has the method. + /// The field name. + /// Whether to throw an exception if the private field is not found. + IPrivateMethod GetPrivateMethod(Type type, string name, bool required = true); + } +} diff --git a/src/StardewModdingAPI/ModHelper.cs b/src/StardewModdingAPI/ModHelper.cs index 781deff4..1fcc0182 100644 --- a/src/StardewModdingAPI/ModHelper.cs +++ b/src/StardewModdingAPI/ModHelper.cs @@ -3,7 +3,6 @@ using System.IO; using Newtonsoft.Json; using StardewModdingAPI.Advanced; using StardewModdingAPI.Framework.Reflection; -using StardewModdingAPI.Reflection; namespace StardewModdingAPI { diff --git a/src/StardewModdingAPI/Reflection/IPrivateField.cs b/src/StardewModdingAPI/Reflection/IPrivateField.cs deleted file mode 100644 index f758902f..00000000 --- a/src/StardewModdingAPI/Reflection/IPrivateField.cs +++ /dev/null @@ -1,26 +0,0 @@ -using System.Reflection; - -namespace StardewModdingAPI.Reflection -{ - /// A private field obtained through reflection. - /// The field value type. - public interface IPrivateField - { - /********* - ** Accessors - *********/ - /// The reflection metadata. - FieldInfo FieldInfo { get; } - - - /********* - ** Public methods - *********/ - /// Get the field value. - TValue GetValue(); - - /// Set the field value. - //// The value to set. - void SetValue(TValue value); - } -} \ No newline at end of file diff --git a/src/StardewModdingAPI/Reflection/IPrivateMethod.cs b/src/StardewModdingAPI/Reflection/IPrivateMethod.cs deleted file mode 100644 index 4790303b..00000000 --- a/src/StardewModdingAPI/Reflection/IPrivateMethod.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System.Reflection; - -namespace StardewModdingAPI.Reflection -{ - /// A private method obtained through reflection. - public interface IPrivateMethod - { - /********* - ** Accessors - *********/ - /// The reflection metadata. - MethodInfo MethodInfo { get; } - - - /********* - ** Public methods - *********/ - /// Invoke the method. - /// The return type. - /// The method arguments to pass in. - TValue Invoke(params object[] arguments); - - /// Invoke the method. - /// The method arguments to pass in. - void Invoke(params object[] arguments); - } -} \ No newline at end of file diff --git a/src/StardewModdingAPI/Reflection/IReflectionHelper.cs b/src/StardewModdingAPI/Reflection/IReflectionHelper.cs deleted file mode 100644 index f5d7d547..00000000 --- a/src/StardewModdingAPI/Reflection/IReflectionHelper.cs +++ /dev/null @@ -1,53 +0,0 @@ -using System; - -namespace StardewModdingAPI.Reflection -{ - /// Simplifies access to private game code. - public interface IReflectionHelper - { - /********* - ** Public methods - *********/ - /// Get a private instance field. - /// The field type. - /// The object which has the field. - /// The field name. - /// Whether to throw an exception if the private field is not found. - IPrivateField GetPrivateField(object obj, string name, bool required = true); - - /// Get a private static field. - /// The field type. - /// The type which has the field. - /// The field name. - /// Whether to throw an exception if the private field is not found. - IPrivateField GetPrivateField(Type type, string name, bool required = true); - - /// Get the value of a private instance field. - /// The field type. - /// The object which has the field. - /// The field name. - /// Whether to throw an exception if the private field is not found. - /// This is a shortcut for followed by . - TValue GetPrivateValue(object obj, string name, bool required = true); - - /// Get the value of a private static field. - /// The field type. - /// The type which has the field. - /// The field name. - /// Whether to throw an exception if the private field is not found. - /// This is a shortcut for followed by . - TValue GetPrivateValue(Type type, string name, bool required = true); - - /// Get a private instance method. - /// The object which has the method. - /// The field name. - /// Whether to throw an exception if the private field is not found. - IPrivateMethod GetPrivateMethod(object obj, string name, bool required = true); - - /// Get a private static method. - /// The type which has the method. - /// The field name. - /// Whether to throw an exception if the private field is not found. - IPrivateMethod GetPrivateMethod(Type type, string name, bool required = true); - } -} diff --git a/src/StardewModdingAPI/StardewModdingAPI.csproj b/src/StardewModdingAPI/StardewModdingAPI.csproj index 5f380cc6..4e547fa0 100644 --- a/src/StardewModdingAPI/StardewModdingAPI.csproj +++ b/src/StardewModdingAPI/StardewModdingAPI.csproj @@ -184,9 +184,9 @@ - - - + + + -- cgit