private void Include(IList<string> includes, Action action)
{
if (includes != null)
{
foreach (var include in includes)
action(<add include here>);
}
}
Run Code Online (Sandbox Code Playgroud)
我想这样称呼它
this.Include(includes, _context.Cars.Include(<NEED TO PASS each include to here>));
Run Code Online (Sandbox Code Playgroud)
这个想法是将每个包含传递给方法.
以前我有过
Dispatcher.Invoke(new Action(() => colorManager.Update()));
Run Code Online (Sandbox Code Playgroud)
从另一个线程更新显示到WPF.由于设计,我不得不改变程序,我必须将ColorImageFrame参数传递给我的ColorStreamManager.Update()方法.
在此链接之后,我将我的调度程序修改为:
Dispatcher.Invoke(new Action<ColorStreamManager, ColorImageFrame>((p,v) => p.Update(v)));
Run Code Online (Sandbox Code Playgroud)
它编译得很好但根本不会运行.VS2010说"参数计数不匹配".在我的ColorStreamManager.Update()方法中,我有
RaisePropertyChanged(() => Bitmap);
有人可以指出我哪里出错了吗?
ColorStreamManager.Update()方法的签名如下:
public void Update(ColorImageFrame frame);
Run Code Online (Sandbox Code Playgroud) 我有一个像这样的方法:
public Something MyMethod()
{
Setup();
Do something useful...
TearDown();
return something;
}
Run Code Online (Sandbox Code Playgroud)
Setup和TearDown方法位于基类中.
我遇到的问题是我必须使用Setup()和TearDown()方法调用一遍又一遍地编写这种类型的方法.
编辑:这个方法的棘手部分是"做一些有用的东西......"仅适用于此方法.这个部分对我创建的每个方法都不同.
另外,我可以将MyMethod2,MyMethod3放在一个类中.在所有情况下,我想运行设置和拆解
有没有一种优雅的方式来做到这一点,而不必每次都写这个?
也许我是妄想,但是这是一种向方法添加属性并拦截方法调用的方法,所以我可以在调用之前和之后做一些事情?