This package of extension methods gives an elegant way to use reflection on all kinds of objects within C#. Below, is a list of methods that are added at an object level, allowing simple and easy access to internal
and private
members.
All that is required is that Lib.Harmony
should be included within your project. This package does not supply Harmony. Once installed, add the following using statement to your class file.
using ApacheTech.Common.Extensions.Harmony;
Method | Description |
---|---|
GetField<T> | Gets a field within the calling instanced object. This can be an internal or private field within another assembly. |
GetFields<T> | Gets an array of fields within the calling instanced object, of a specified Type. These can be an internal or private fields within another assembly. |
SetField | Sets a field within the calling instanced object. This can be an internal or private field within another assembly. |
Method | Description |
---|---|
GetProperty<T> | Gets a property within the calling instanced object. This can be an internal or private property within another assembly. |
SetProperty | Sets a property within the calling instanced object. This can be an internal or private property within another assembly. |
Method | Description |
---|---|
CallMethod | (2 methods) Calls a method within an instance of an object, via reflection. This can be an internal or private method within another assembly. |
CallMethod<T> | Calls a method within an instance of an object, via reflection. This can be an internal or private method within another assembly. |
GetMethod | Gets the for a method within an instance of a class, via reflection. This can be an internal or private method within another assembly. |
Method | Description |
---|---|
GetClassType | Gets the type of the class within an assembly, via reflection. |
CreateInstance | Creates the instance of a specified Type, using Harmony AccessTools. Be aware that this will ignore all Service Providers, and attempt to directly instantiate a class. |
Method | Description |
---|---|
DeepClone<T> | Makes a deep copy of any object. |