.net - 如何在几秒钟内使用 ReSharper 创建方法参数对象?

标签 .net design-patterns refactoring resharper parameter-object

是否可以选择一个方法的所有参数并要求 ReSharper 从这些参数创建一个类作为“方法参数对象”?

最佳答案

ReSharper 支持命令 Extract Class From Parameters :

The Extract Class From Parameters refactoring allows you to quickly create a new class or structure using (some of) the parameters of a given method. ReSharper analyses the selected method and detects the variables that can be converted into members. After extraction, the new class is created with the necessary fields generated from the selected method's parameters.



调用它:
  • 将光标放在方法上
    要为
  • 生成类的参数
  • 按 Ctrl + Shift + R
  • 选择“”从中提取类
    参数
    '
  • 在对话框中进行任何其他配置。
  • 关于.net - 如何在几秒钟内使用 ReSharper 创建方法参数对象?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4067960/

    相关文章:

    c# - 使用 HTMLAgilityPack c# 按类名删除元素

    c# - 一般 GDI+ 错误(错误号 -2147467259)

    .net - 如何将大于 5 MB(大约)的文件上传到 Amazon S3(官方 SDK)?

    c# - 字典可以按不同的键排序吗?

    design-patterns - Hystrix 使用的 Bulkhead 模式是什么?

    ios - 当我重命名属性名称时,Xcode 重构不会重命名 setter 和 getter

    c# - 如何在 C# 中创建空对象

    c# - 在 winforms TreeView 中设置第一个节点的位置/边距

    c# - 装饰器和虚拟方法

    html - 重构 HTML 和 CSS