使用模式方法调用的 Resharper 搜索
Resharper Search with pattern method call
我想用 "Search with pattern..." 替换这部分代码:
public bool IsDbObjectsOK()
{
var result = 0;
result = usp_IsDbObjectsOK();
if (result == 0)
return true;
return false;
}
public bool UnlockWindow()
{
var result = 0;
result = usp_UnlockWindow();
if (result == 0)
return true;
return false;
}
替换为:
public bool IsDbObjectsOK()
{
return usp_IsDbObjectsOK() == 0;
}
public bool UnlockWindow()
{
return usp_UnlockWindow() == 0;
}
我尝试使用
var $result$ = 0;
$result$ = $usp_IsDbObjectsOK$();
if ($result$ == 0)
return true;
return false;
这不起作用,因为在任何需要替换的代码中都找不到方法调用。
如何操作?
您需要确保在设置搜索时使用正确的placeholder type。
这里,result
应该是一个 标识符占位符 ,usp_IsDbObjectsOK
应该是一个 表达式占位符 。当我这样做时,替换会如您所愿地工作。
我想用 "Search with pattern..." 替换这部分代码:
public bool IsDbObjectsOK()
{
var result = 0;
result = usp_IsDbObjectsOK();
if (result == 0)
return true;
return false;
}
public bool UnlockWindow()
{
var result = 0;
result = usp_UnlockWindow();
if (result == 0)
return true;
return false;
}
替换为:
public bool IsDbObjectsOK()
{
return usp_IsDbObjectsOK() == 0;
}
public bool UnlockWindow()
{
return usp_UnlockWindow() == 0;
}
我尝试使用
var $result$ = 0;
$result$ = $usp_IsDbObjectsOK$();
if ($result$ == 0)
return true;
return false;
这不起作用,因为在任何需要替换的代码中都找不到方法调用。
如何操作?
您需要确保在设置搜索时使用正确的placeholder type。
这里,result
应该是一个 标识符占位符 ,usp_IsDbObjectsOK
应该是一个 表达式占位符 。当我这样做时,替换会如您所愿地工作。