ObjPropsDynamicSetter 0.4.3
dotnet add package ObjPropsDynamicSetter --version 0.4.3
NuGet\Install-Package ObjPropsDynamicSetter -Version 0.4.3
<PackageReference Include="ObjPropsDynamicSetter" Version="0.4.3" />
paket add ObjPropsDynamicSetter --version 0.4.3
#r "nuget: ObjPropsDynamicSetter, 0.4.3"
// Install ObjPropsDynamicSetter as a Cake Addin #addin nuget:?package=ObjPropsDynamicSetter&version=0.4.3 // Install ObjPropsDynamicSetter as a Cake Tool #tool nuget:?package=ObjPropsDynamicSetter&version=0.4.3
ObjPropsDynamicSetter
A small library providing object extensions for getting properties information and manipulating their values via property names known at runtime. Uses reflection under the hood. Might be useful for playing with models properties in data-driven testing, but not limited to it. Supports nested properties access and access to non-public properties.
Use
Simple usage examples:
var model = new Model();
var propertyName = "Foo";
// PropertyInfo retrieval from a property
var propertyInfo = model.GetPropertyInfo(propertyName);
// Property value retrieval
var propertyValue = model.GetPropertyValue(propertyName);
// Setting new value to a property
var value = 1000;
model.SetPropertyValue(propertyName, value);
Public properties are accessible by default. To access non-public ones, optional parameter 'includeNonPublic' should be set to 'true':
model.SetPropertyValue(propertyName, value, true);
To access nested property, full path should be specified with dot ('.') as delimiter:
public class Model
{
public NestedModel NestedModel { get; set; }
}
public class NestedModel
{
public int Bar { get; set; }
}
// Internal initialization logic skipped for simplicity
var model = new Model();
var propertyName = "NestedModel.Bar";
var value = model.GetPropertyValue(propertyName);
Download
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 is compatible. 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 | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.1 is compatible. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.1
- No dependencies.
-
net5.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.