从Object生成DTO [英] Generate DTOs from Object

查看:563
本文介绍了从Object生成DTO的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要从一些现有的对象中自动生成一些DTO,我想知道是否已经存在一个Resharper,DevExpress或VSX开放源代码,我需要一个工具来查看我的代码,让我选择哪些属性我想包括在我的DTO中,然后根据这个...生成一个类...

解决方案

这是一个黑客,您可以使用Visual Studio / Resharper从类中提取一个接口,然后创建一个DTO类并从该接口派生,然后使用Visual Studio自动实现接口成员(然后,可选地删除接口)。


I want to auto gen some DTOs from some of my existing objects, I was wondering if there already exist a Resharper, DevExpress or VSX open source to use, I need a tool to look into my code and let me choose which properties I want to include in my DTO and then generate a class based on that...

解决方案

This is kind of a hack but you could use Visual Studio/Resharper to Extract an interface from the class, then create a DTO class and derive from the interface, then use Visual Studio to auto implement the interface members (then, optionally remove the interface).

这篇关于从Object生成DTO的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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