开发者

Use of "@this" in Moles delegates

When I set a property of a moled type, it looks like they always require, as the first parameter, an object of the original moled type. I also noti开发者_如何学运维ced that some of the examples in the Moles Reference Guide assign this parameter as @this and I am trying to figure out why.

For instance, the original class looks something like this:

public class ProductDAO
{
    internal void Insert(Product product, string id)
    {
        ...
    }
}

When I go to mole this method, the property is expecting a delegate whose first parameter is always the type of the moled object, in this case, a ProductDAO object. So in this case, the property is expecting a delegate of:

Action<ProductDAO, Product, string>

So do I always have to provide that moled object as the first parameter of my lambda expression? If so, what's the difference in using a regular variable name versus @this? What does @this mean/do?

MProductDAO.AllInstances.InsertProductString = (dao, product, id) => { };

versus

MProductDAO.AllInstances.InsertProductString = (@this, product, id) => { };
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜