ExpressWalker 1.0.0.8

There is a newer version of this package available.
See the version list below for details.
dotnet add package ExpressWalker --version 1.0.0.8
NuGet\Install-Package ExpressWalker -Version 1.0.0.8
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="ExpressWalker" Version="1.0.0.8" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add ExpressWalker --version 1.0.0.8
#r "nuget: ExpressWalker, 1.0.0.8"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install ExpressWalker as a Cake Addin
#addin nuget:?package=ExpressWalker&version=1.0.0.8

// Install ExpressWalker as a Cake Tool
#tool nuget:?package=ExpressWalker&version=1.0.0.8

ExpressWalker provides a generic way to examine and change any object graph in fashion similar to "Visitor Pattern". You can build generic hierarchy composition (visitor) capable to "visit" and change any property, basing on configuration. Uses refleciton only while building a visitor and relies purely on expression trees while visiting objects.

That's why IT IS WAY FASTER than custom solutions usually built with reflection.

It is optionally protected from circular references so you can avoid StackOverflowException easily. Provides fluent API while building a visitor which increases code readability in terms of recognizing the hierarchy being built right away from the code. The optional and configurable things available are:

- visiting properties by matching owner type and property name
- visiting properties by matching property type only
- specifying depth of visit in run-time (not during configuration)
- custom expression for changing property value
- cloning of visited object
- etc.

//building a visitor + visiting an object (with optional clone, visit depth and circular reference protection):

var visitor = TypeWalker<Parent>.Create()
                 .ForProperty<Parent, string>(p => p.TestString1, null, (old, met) => old + met)
                 .ForProperty<Child, DateTime>(p => p.TestDate1, null, (old, met) => old.AddYears(10))
                 .ForProperty<CommonType>(null, (old, met) => new CommonType { CommonString = "..." })
                 .Build();

 var parentClone = new Parent();

 visitor.Visit(parentObject, parentClone, 10, new InstanceGuard());

// The properties that are being visited and change here are:
// 1. 'TestString1' property of Parent objects, anywhere in Parent's hierarchy
// 2. 'TestDate1' property of Child objects, anywhere in Parent's hierarchy
// 3.  Any property of type CommonType, anywhere in Parent's hierarchy

//Property setter: new value for property 'TestString1' is set by compiled expression '(old, met) => old + met'
//'old' is old value, 'met' is metadata obj. coming from [VisitorMetadata] attribute on 'TestString1' property.

There is also an option of ManualWaler for building more specific visitor that will visit only nodes in specific place in object graph (e.g. only a 'Child' element at level 3 and only it's 'TestString1' property).

Many thanks to Francisco José Rey Gozalo for contributing with ideas and solutions.

Product Compatible and additional computed target framework versions.
.NET Framework net is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
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
2.1.0.1 2,283 4/1/2018
1.4.0.2 2,083 9/10/2016
1.4.0.1 2,079 9/8/2016
1.3.1.3 2,002 9/7/2016
1.3.1.2 2,078 9/7/2016
1.3.0.3 2,044 8/17/2016
1.3.0.2 2,059 8/17/2016
1.3.0.1 2,110 8/16/2016
1.2.0.2 2,000 8/16/2016
1.2.0.1 1,994 8/9/2016
1.1.0.5 2,059 8/7/2016
1.1.0.4 2,033 8/7/2016
1.1.0.3 2,100 8/7/2016
1.1.0.2 2,009 8/7/2016
1.0.0.12 2,054 8/4/2016
1.0.0.10 2,043 8/3/2016
1.0.0.9 2,061 8/3/2016
1.0.0.8 2,056 8/3/2016
1.0.0.7 1,991 8/3/2016

Initial stable version