簡體   English   中英

Resharper使用模式方法調用搜索

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM