# Newbe.ObjectVisitor **Repository Path**: wtf3505/Newbe.ObjectVisitor ## Basic Information - **Project Name**: Newbe.ObjectVisitor - **Description**: Newbe.ObjectVisitor 帮助开发者可以用最简单的最高效的方式访问一个普通 class 的所有属性。从而实现:验证、映射、收集等等操作 - **Primary Language**: C# - **License**: MIT - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 6 - **Created**: 2021-02-12 - **Last Updated**: 2021-02-12 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Newbe.ObjectVisitor - [简体中文](README_zh_Hans.md) - [English](README.md) [![All Contributors](https://img.shields.io/badge/all_contributors-2-orange.svg?style=flat-square)](#contributors-) - [![build and scan](https://github.com/newbe36524/Newbe.ObjectVisitor/workflows/build%20and%20scan/badge.svg)](https://github.com/newbe36524/Newbe.ObjectVisitor/actions?query=workflow%3A%22build+and+scan%22) - [![Codecov](https://img.shields.io/codecov/c/github/newbe36524/Newbe.ObjectVisitor)](https://codecov.io/gh/newbe36524/Newbe.ObjectVisitor) - [![Coverage](https://sonarcloud.io/api/project_badges/measure?project=newbe36524_Newbe.ObjectVisitor&metric=coverage)](https://sonarcloud.io/dashboard?id=newbe36524_Newbe.ObjectVisitor) - [![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=newbe36524_Newbe.ObjectVisitor&metric=alert_status)](https://sonarcloud.io/dashboard?id=newbe36524_Newbe.ObjectVisitor) - [![Codacy Badge](https://api.codacy.com/project/badge/Grade/1fd0e7443364414ca0003dab27f9f9b8)](https://www.codacy.com/manual/472158246/Newbe.ObjectVisitor?utm_source=github.com&utm_medium=referral&utm_content=newbe36524/Newbe.ObjectVisitor&utm_campaign=Badge_Grade) - xml document [![Crowdin](https://badges.crowdin.net/newbeobjectvisitor/localized.svg)](https://crowdin.com/project/newbeobjectvisitor) - documents [![Crowdin](https://badges.crowdin.net/newbeobjectvisitordocs/localized.svg)](https://crowdin.com/project/newbeobjectvisitordocs) ![Banner](https://github.com/newbe36524/Newbe.ObjectVisitor/raw/docs/assets/banner.svg) You can visit all properties about your class by this lib with high performance as you visit properties in hard coding way. For example, here is object in your code. ```cs var order = new OrderInfo(); ``` And, you want to print all properties of the order. ```cs for(var pInfo in typeof(OrderInfo).GetProperties()) { Console.Writeline($"{pInfo.Name}: {pInfo.GetValue(order)}"); } ``` By using this lib, you can handle it in this way: ```cs // call .V what is a static extension method // you get a visitor object for order var visitor = order.V(); visitor.ForEach(context=>{ var name = context.Name; var value = context.Value; Console.Writeline($"{name}: {value}"); }).Run(); // you can also make it into one line order.V().ForEach(c=> Console.Writeline($"{c.Name}: {c.Value}")).Run(); // or using quick style order.FormatToString(); ``` ## Why do I need this? - **It is faster.** This lib is impletmented with [Expression Trees](https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/concepts/expression-trees/) that cost 1/10 time as in Reflection way. - **It is readable.** This lib can generate a lambda func to handle the code flow you create that just as your hard coding without reflection. - **It is extendable.** If you can visit all properties of a object in easy way, you can validate them as you wish, change some value if there are something sensitive, creare a mapper like automapper, and etc. ## API Please check out the latest full API documents in site below: - - more faster to China mainland - ## Packages | package | version | download | descrption | | ------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------ | | Newbe.ObjectVisitor | [![Newbe.ObjectVisitor.Version](https://img.shields.io/nuget/v/Newbe.ObjectVisitor.svg?style=flat-square)](https://www.nuget.org/packages/Newbe.ObjectVisitor/) | [![Newbe.ObjectVisitor.Download](https://img.shields.io/nuget/dt/Newbe.ObjectVisitor.svg?style=flat-square)](https://www.nuget.org/packages/Newbe.ObjectVisitor/) | Core about Newbe.ObjectVisitor | ## Contact QQ Group: 【Newbe.Claptrap CL4P-TP 610394020 】: ## Stargazers over time [![Stargazers over time](https://starchart.cc/newbe36524/Newbe.ObjectVisitor.svg)](https://starchart.cc/newbe36524/Newbe.ObjectVisitor) ## Contributors ✨ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):

Newbe36524

📝 💻 📖

kotone

🎨
This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!