ExpressWalker 1.1.0.3

There is a newer version of this package available.
See the version list below for details.
dotnet add package ExpressWalker --version 1.1.0.3
NuGet\Install-Package ExpressWalker -Version 1.1.0.3
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.1.0.3" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add ExpressWalker --version 1.1.0.3
#r "nuget: ExpressWalker, 1.1.0.3"
#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.1.0.3

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

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 object's property, basing on configuration. Uses reflection 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. Some of functionalities available are visiting properties by matching owner type and name (or only type), specifying depth of visit, custom expression for changing property value, clonging etc.

//example 1 - IVisitor that visits properties by property names and/or types (start from TypeWalker class):

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

 var parentClone = new Parent();
 var propertyValues = new HashSet<PropertyValue>()
 typeVisitor.Visit(parentObject, parentClone, 10, new InstanceGuard(), propertyValues);
 
//example 2 - IVisitor that visits properties by explicit configuration (start from ManualWalker class):

 var manualVisitor = ManualWalker.Create<A1>()
                                   .Property<A1, DateTime>(a1 => a1.A1Date, (va1, met) => va1.AddYears(10))
                                   .Element<A1, B1>(a1 => a1.B1, b1 =>
                                           b1.Property<B1, string>(x => x.B1Name, (vb1, met) => vb1 + "Test2"))
                                   .Element<A1, B2>(a1 => a1.B2, b2 => b2
                                           .Property<B2, DateTime>(x => x.B2Date, (vb2, met) => vb2.AddYears(10)))
                               .Build();

 var parentClone = new A1();
 var propertyValues = new HashSet<PropertyValue>()
 manualVisitor.Visit(parentObject, parentClone, 10, new InstanceGuard(), propertyValues);

//Paremeter 'met' in expressions above is optional metadata object set in design-time.
//It can be set by [VisitorMetadata] property attribute in visited class.
//e.g. in example above, there is [VisitorMetadata("AnyString")] on property Parent.TestString1.

Many thanks to Francisco José Rey Gozalo for contributing with ideas and solutions.
Read more on https://github.com/kopalite/ExpressWalker

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,215 4/1/2018
1.4.0.2 2,022 9/10/2016
1.4.0.1 2,004 9/8/2016
1.3.1.3 1,938 9/7/2016
1.3.1.2 2,019 9/7/2016
1.3.0.3 1,992 8/17/2016
1.3.0.2 1,978 8/17/2016
1.3.0.1 2,032 8/16/2016
1.2.0.2 1,931 8/16/2016
1.2.0.1 1,918 8/9/2016
1.1.0.5 1,998 8/7/2016
1.1.0.4 1,971 8/7/2016
1.1.0.3 2,031 8/7/2016
1.1.0.2 1,938 8/7/2016
1.0.0.12 1,982 8/4/2016
1.0.0.10 1,985 8/3/2016
1.0.0.9 1,999 8/3/2016
1.0.0.8 2,002 8/3/2016
1.0.0.7 1,922 8/3/2016

Initial stable version