Ministry.Reflection
4.0.0
See the version list below for details.
dotnet add package Ministry.Reflection --version 4.0.0
NuGet\Install-Package Ministry.Reflection -Version 4.0.0
<PackageReference Include="Ministry.Reflection" Version="4.0.0" />
paket add Ministry.Reflection --version 4.0.0
#r "nuget: Ministry.Reflection, 4.0.0"
// Install Ministry.Reflection as a Cake Addin #addin nuget:?package=Ministry.Reflection&version=4.0.0 // Install Ministry.Reflection as a Cake Tool #tool nuget:?package=Ministry.Reflection&version=4.0.0
Ministry.ReflectionHelper
This project is set up to make the process of Reflection in .net much easier to code than it is using the standard methods provided by the framework by applying core features through a simple API. I always found the .net Reflection methods quite unwieldy and unintuitive.
Fields
The following methods exist for fields...
Ministry.ReflectionHelper.Field.Exists()
Traditional and generic variants of this method can be called either passing in a type or a value of a given type along with a field name to look for on that type.
Ministry.ReflectionHelper.Field.Get()
Traditional and generic variants of this method can be called by passing in an object to query along with a field name. For example...
Field.Get(myObj, "name");
Overloads are also provided for static types that take a type parameter instead of an object instance.
Ministry.ReflectionHelper.Field.Set()
Traditional and generic variants of this method can be called by passing in an object to query along with a field name to set. For example...
Field.Set(myObj, "name", "new value");
Overloads are also provided for static types that take a type parameter instead of an object instance.
Ministry.ReflectionHelper.Field.GetInfo()
Sometimes you do need the Info objects but in traditional .net code this can become quite awkward if the object you are looking for is further down the inheritance tree than the layer that you are interrogating. Ministry.ReflectionHelper wraps up all of the code required to recurse down the inheritance tree to find the type that you are looking for. This method also provides the same service to the rest of the Field class, enabling the helper to provide Reflection against the whole inheritance tree.
Properties
Reflection on Fields & Properties are similar. The following methods exist for properties...
Ministry.ReflectionHelper.Property.Exists()
Traditional and generic variants of this method can be called either passing in a type or a value of a given type along with a property name to look for on that type.
Ministry.ReflectionHelper.Property.IsReadOnly()
Traditional and generic variants of this method can be called either passing in a type or a value of a given type along with a property name to look for on that type.
Ministry.ReflectionHelper.Property.Get()
Traditional and generic variants of this method can be called by passing in an object to query along with a property name. For example...
Property.Get(myObj, "Name");
Overloads are also provided for static types that take a type parameter instead of an object instance.
Ministry.ReflectionHelper.Property.Set()
Traditional and generic variants of this method can be called by passing in an object to query along with a property name to set. For example...
Property.Set(myObj, "Name", "new value");
Overloads are also provided for static types that take a type parameter instead of an object instance.
Ministry.ReflectionHelper.Property.GetInfo()
Sometimes you do need the Info objects but in traditional .net code this can become quite awkward if the object you are looking for is further down the inheritance tree than the layer that you are interrogating. Ministry.ReflectionHelper wraps up all of the code required to recurse down the inheritance tree to find the type that you are looking for. This method also provides the same service to the rest of the Properties class, enabling the helper to provide Reflection against the whole inheritance tree.
Ministry.ReflectionHelper.Property.Indexer.GetItem()
Traditional and generic variants of this method can be called by passing in an object to query along with a property name and an index. For example...
Property.Indexer.GetIItem(myObj, "Index", 4);
Ministry.ReflectionHelper.Property.Indexer.SetItem()
Traditional and generic variants of this method can be called by passing in an object to query along with a property name and an index to set. For example...
Property.Indexer.SetItem(myObj, "Index", 4, "new value");
Methods
The following methods exist for methods. Method access through Reflection is very problematic. The Methods class within Ministry.ReflectionHelper, as with Fields and Properties, benefits from inheritance tree recursion.
Ministry.ReflectionHelper.Method.Execute()
Many overloaded variants of this exist to call a method with or without parameters. The method execution code will search for the method to execute using the method below.
Ministry.ReflectionHelper.Method.GetInfo()
Sometimes you do need the Info objects but in traditional .net code this can become quite awkward if the object you are looking for is further down the inheritance tree than the layer that you are interrogating. Ministry.ReflectionHelper wraps up all of the code required to recurse down the inheritance tree to find the type that you are looking for.
Ministry.ReflectionHelper.Method.GetParameters()
Provides you with the info about the parameters for a given method.
Summary
That's the key functionality of the Ministry.ReflectionHelper classes. If you want to do any kind of deep reflection and you don't have the joy of the Dynamic Language Runtime to help you out then I hope you'll find some of the methods in these classes really useful. If you want to find out any more, simply check out the source code.
Upgrading v3.x to v4.x
If you are upgrading from v2 or v3 to v4 you may find breaking changes. In v4 we have added some helpful extension methods and moved support away from the stanadrd .net framework to NETSTandard 1.6 to support dotnet core.
The Ministry of Technology Open Source Products
Welcome to The Ministry of Technology open source products. All open source Ministry of Technology products are distributed under the MIT License for maximum re-usability. Details on more of our products and services can be found on our website at http://www.ministryotech.co.uk
Our other open source repositories can be found here...
Newer content prefers Github. Bitbucket is no longer actively used.
Where can I get it?
You can download the package for this project from any of the following package managers...
Contribution guidelines
If you would like to contribute to the project, please contact me.
Who do I talk to?
- Keith Jackson - keith@ministryotech.co.uk
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp1.0 was computed. netcoreapp1.1 was computed. netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard1.6 is compatible. netstandard2.0 was computed. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen30 was computed. tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 1.6
- Ministry.FluentGuard (>= 1.0.0)
- NETStandard.Library (>= 1.6.1)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Ministry.Reflection:
Package | Downloads |
---|---|
Ministry.Compositions
Library of Functional Composition Extension Methods |
GitHub repositories
This package is not used by any popular GitHub repositories.