Newbe.ObjectVisitor helps developers access all the properties of a normal class in the simplest and most efficient way.This enables:validation, mapping, collection, and more.
For example, there is such a simple class in your code.
var order = new OrderInfo();
If you want to print out all the properties and values of this class, you can use reflection to:
for(var pInfo in typeof(OrderInfo).GetProperties())
{
Console.Writeline($"{pInfo.Name}: {pInfo.GetValue(order)}");
}
If you use this class library, you can achieve the same effect by:
// invoke .V
// there is a visitor for OrderInfo
var visitor = order.V();
visitor.ForEach(context=>{
var name = context.Name;
var value = context.Value;
Console.Writeline($"{name}: {value}");
}).Run();
// it can be joined into one line.
order.V().ForEach(c=> Console.Writeline($"{c.Name}: {c.Value}")).Run();
// or shorter
order.FormatToString();
You can click here to get into the "Quick Start" and learn about the full documents
We still need more friends to get involved in this intense project.
You can click here for detailed contributions