Oakrey.Reflection
2.1.0
dotnet add package Oakrey.Reflection --version 2.1.0
NuGet\Install-Package Oakrey.Reflection -Version 2.1.0
<PackageReference Include="Oakrey.Reflection" Version="2.1.0" />
<PackageVersion Include="Oakrey.Reflection" Version="2.1.0" />
<PackageReference Include="Oakrey.Reflection" />
paket add Oakrey.Reflection --version 2.1.0
#r "nuget: Oakrey.Reflection, 2.1.0"
#:package Oakrey.Reflection@2.1.0
#addin nuget:?package=Oakrey.Reflection&version=2.1.0
#tool nuget:?package=Oakrey.Reflection&version=2.1.0
Oakrey.Reflection
Oakrey.Reflection provides focused helpers for common .NET reflection tasks: loading assemblies, working with enums, finding implementors, creating instances, clearing event handlers, and setting properties dynamically.
Features
AppDomainExtensionsloads assemblies from the current application directory or a selected directory and skips assemblies that are already loaded.Enumsreads enum descriptions, enumerates values, converts enums by name or value, and exposes non-throwing conversion helpers.Eventsclears typed event delegates and removes field-like event handlers from an object, including inherited events.PropertyReflectionsets public properties dynamically with invariant-culture conversion, enum parsing, nullable support, and optional case-insensitive lookup.TypeExtensionsfinds concrete implementors, caches allow-list searches safely, creates instances, and provides aTryCreateInstanceOfBasehelper.
Installation
dotnet add package Oakrey.Reflection
Package Manager Console:
Install-Package Oakrey.Reflection
Examples
Set a property dynamically:
Soldier soldier = new();
bool changed = soldier.TrySetProperty("Rank", "Major");
bool changedCaseInsensitive = soldier.TrySetProperty("rank", "General", ignoreCase: true);
Convert enum values safely:
if (sourceRank.TryConvertByNameTo<TargetRank>(out TargetRank targetRank))
{
Console.WriteLine(targetRank);
}
Find implementors in selected assemblies:
List<Type> commands = typeof(ICommand).GetImplementors(["MyCompany.MyApp"]);
Create an instance without throwing:
if (typeof(MyService).TryCreateInstanceOfBase<IMyService>(out IMyService? service))
{
service.Run();
}
Clear field-like event subscriptions:
publisher.UnsubscribeAllEventHandlers();
Notes
- Reflection can bypass normal compile-time guarantees.
TrySetPropertytherefore rejectsnullfor non-nullable properties when nullable metadata is available. GetImplementors(type, allowList)filters by assembly full name and returns a defensive copy of cached results.LoadAssembliescatches common load failures such asBadImageFormatException,FileLoadException, andFileNotFoundExceptionand writes diagnostics to trace output.
Requirements
- .NET 10 or higher
Project Information
- Author: Oakrey
- Company: Oakrey (Website)
- License: MIT
- Repository: Git Repository
- Project URL: NuGet
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- No dependencies.
NuGet packages (4)
Showing the top 4 NuGet packages that depend on Oakrey.Reflection:
| Package | Downloads |
|---|---|
|
Oakrey.ValueSystem.Base
The Oakrey.ValueSystem library provides a framework for managing and transforming values in .NET applications. It supports various value types, content transformations, and value sources, enabling developers to build dynamic and data-driven applications. |
|
|
Oakrey.Applications.ViewModels
Base ViewModel utilities for MVVM/.NET applications. Provides IAutoConfigurable marker interfaces (singleton, scoped, transient) and an IServiceCollection extension that automatically discovers and registers all ViewModels via reflection — no manual DI wiring required. |
|
|
Oakrey.Peak.Lin.Driver
A .NET 10 high-level LIN driver built on Oakrey.Peak.Lin.Wrapper. Exposes IPeakLinClient and ISlaveClient with Rx observable streams for received messages and bus state changes. Supports master and slave operation modes, timer-based polling, frame publisher/subscriber configuration, and hardware discovery for Peak LIN hardware on Windows. |
|
|
Oakrey.UHD
A .NET P/Invoke wrapper for the Ettus Research UHD (USRP Hardware Driver) native library. Enables TX streaming, frequency and gain tuning, stream metadata handling, and structured logging via IObservable for USRP software-defined radio devices. |
GitHub repositories
This package is not used by any popular GitHub repositories.