[英]Resharper Search with pattern method call
我想用“使用模式搜索...”替換這部分代碼:
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;
這不起作用,因為在任何需要替換的代碼中都找不到方法調用。
這該怎么做?
設置搜索時,需要確保使用正確的占位符類型 。
這里, result
應該是標識符占位符 , usp_IsDbObjectsOK
應該是表達式占位符 。 當我這樣做時,替換工作正如您所期望的那樣。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.