我正在尝试使用NRefactory进行重构, 我有一个用非OOP风格编写的旧样式代码
我需要做的是为每个类T移动静态方法接受T作为第一个参数类型到新的类ExtensionsForT并更改对它的引用看起来像X.method1(t)=&gt; t.method1()< / p>
//------------------original-------------------------------------------
class BigClass{
//method is referenced here
public BigClass(){
Reader r=new Reader();
//...
Next(r);
}
//method to refactor
public static bool Next( Reader r){
//...
}
}
//-------------------- want to achieve this-------------------------
class BigClass{
//method is referenced here
public BigClass(){
Reader r=new Reader();
//...
r.Next();
}
}
public class ReaderExtensions{
//method to refactor
public static bool Next(this Reader r){
//...
}
}