合并一个类的许多实例 [英] Merge many instances of a class

查看:96
本文介绍了合并一个类的许多实例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我正在寻找合并同一类的许多实例的通用解决方案。

例如,对于一个属性:

- 如果至少在值上有所不同,该属性将被设置为默认值

- 如果所有值都相同,则该属性将设置为公共值





您有提示吗?



我尝试了什么:



我查了一下Auto Mapper但它看起来很重这个解决方案。

解决方案

也许 Resharper 重构选项Extract Superclass或Pull Members Up可能是您感兴趣的:< a href =https://www.jetbrains.com/resharper/features/code_refactoring.html> C#的代码重构& .NET - 功能| ReSharper [ ^ ]

Hi,

I'm looking for a generic solution to merge many instances of the same class.
For example, for a property :
- If at least on value is different, the property will be set to a default value
- If all values are the same, the property will be set to the common value


Do you have some tips ?

What I have tried:

I checked Auto Mapper but it seems a very heavy solution for this.

解决方案

Maybe Resharper refactoring options "Extract Superclass" or "Pull Members Up" might be of interest to you: Code Refactorings for C# & .NET - Features | ReSharper[^]


这篇关于合并一个类的许多实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆