![]() |
VOOZH | about |
dotnet add package Ministry.Reflection --version 5.0.0
NuGet\Install-Package Ministry.Reflection -Version 5.0.0
<PackageReference Include="Ministry.Reflection" Version="5.0.0" />
<PackageVersion Include="Ministry.Reflection" Version="5.0.0" />Directory.Packages.props
<PackageReference Include="Ministry.Reflection" />Project file
paket add Ministry.Reflection --version 5.0.0
#r "nuget: Ministry.Reflection, 5.0.0"
#:package Ministry.Reflection@5.0.0
#addin nuget:?package=Ministry.Reflection&version=5.0.0Install as a Cake Addin
#tool nuget:?package=Ministry.Reflection&version=5.0.0Install as a Cake Tool
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.
The following methods exist for fields...
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.
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.
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.
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.
Reflection on Fields & Properties are similar. The following methods exist for properties...
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.
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.
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.
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.
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.
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);
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");
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.
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.
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.
Provides you with the info about the parameters for a given method.
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.
If you are upgrading from v2 or v3 to v4 or v5 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. v5 No longer supports .net Standard and .net Framework.
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. Our other open source repositories can be found here...
You can download the package for this project from any of the following package managers...
If you would like to contribute to the project, please contact me.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net6.0 net6.0 is compatible. net6.0-android net6.0-android was computed. net6.0-ios net6.0-ios was computed. net6.0-maccatalyst net6.0-maccatalyst was computed. net6.0-macos net6.0-macos was computed. net6.0-tvos net6.0-tvos was computed. net6.0-windows net6.0-windows was computed. net7.0 net7.0 was computed. net7.0-android net7.0-android was computed. net7.0-ios net7.0-ios was computed. net7.0-maccatalyst net7.0-maccatalyst was computed. net7.0-macos net7.0-macos was computed. net7.0-tvos net7.0-tvos was computed. net7.0-windows net7.0-windows was computed. net8.0 net8.0 is compatible. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 was computed. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 was computed. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
Showing the top 1 NuGet packages that depend on Ministry.Reflection:
| Package | Downloads |
|---|---|
|
Ministry.Compositions
Library of Functional Composition Extension Methods |
This package is not used by any popular GitHub repositories.