ObjectWriter 1.0.0

.NET Framework 4.0
dotnet add package ObjectWriter --version 1.0.0
NuGet\Install-Package ObjectWriter -Version 1.0.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="ObjectWriter" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add ObjectWriter --version 1.0.0
#r "nuget: ObjectWriter, 1.0.0"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install ObjectWriter as a Cake Addin
#addin nuget:?package=ObjectWriter&version=1.0.0

// Install ObjectWriter as a Cake Tool
#tool nuget:?package=ObjectWriter&version=1.0.0

Sets the value to a property of an object by its path from the root.



The object can be a complex object and the property can be multi level deep nested property or it can be a property directly under the root. ObjectWriter will find the property using the property path parameter and update its value. Property path is the appended names of the properties visited from root to the end node property which we want to set, delimited by the delimiter string parameter.  

Usage:

For setting up the properties directly under the object root:
Ie. LineItem class has an int property called ItemId
LineItem lineItem = new LineItem();

ObjectWriter.Set(lineItem, "ItemId", 13, delimiter: null);

For setting up nested property multiple levels below the object root:
Ie. Invite class has a property called State, which has a property called Recipient, which has a property called Id.
Here is how you can set the Id property (to string value of “outlook”) at the bottom of the object tree in a single line.
Invite invite = new Invite();
ObjectWriter.Set(invite, "State_Recipient_Id", "outlook", delimiter: "_");
This will set invite.State.Recipient.Id to “outlook”
You also do not need to worry about instantiating the properties State or Recipient, ObjectWriter.Set method will instantiate those if they are null along the way.

Product Versions
.NET Framework net40 net403 net45 net451 net452 net46 net461 net462 net463 net47 net471 net472 net48 net481
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.

This package has 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.

Version Downloads Last updated
1.0.0 3,221 9/21/2016

Initial release.