我在C#中有一个接口,可以帮助从服务器上的自定义存档中检索数据.界面如下所示:
public interface IRetrieveData
{
bool OkToRetrieve(SomeData data); // Method in question...
bool RetrieveToLocal(SomeData data);
}
Run Code Online (Sandbox Code Playgroud)
此接口由将数据检索到本地数据库的客户端实现.有不同类型的客户端可以访问彼此的数据.因此,当处理组件IRetrieveData.OkToRetrieve在实际检索之前调用时,调用将转到客户端代码,在该客户端代码中决定是否应该检索数据.
此时,客户端可以返回false并跳过该数据或返回true,处理组件调用RetrieveToLocal并将数据发送到客户端,然后客户端处理它.
当我越来越困惑是是否要重命名的方法OkToRetrieve,只是Retrieve或者CanRetrieve或留作OkToRetrieve.
有没有人有任何建议?
我有两种情况:
static void CreateCopyOfString()
{
string s = "Hello";
ProcessString(s);
}
Run Code Online (Sandbox Code Playgroud)
和
static void DoNotCreateCopyOfString()
{
ProcessString("Hello");
}
Run Code Online (Sandbox Code Playgroud)
这两种情况的IL看起来像这样:
.method private hidebysig static void CreateCopyOfString() cil managed
{
// Code size 15 (0xf)
.maxstack 1
.locals init ([0] string s)
IL_0000: nop
IL_0001: ldstr "Hello"
IL_0006: stloc.0
IL_0007: ldloc.0
IL_0008: call void ConsoleApplication1.Program::ProcessString(string)
IL_000d: nop
IL_000e: ret
} // end of method Program::CreateCopyOfString
Run Code Online (Sandbox Code Playgroud)
和
.method private hidebysig static void DoNotCreateCopyOfString() cil managed
{
// Code size 13 (0xd)
.maxstack 8 …Run Code Online (Sandbox Code Playgroud)