开发者

CRMService and ICRMService

开发者 https://www.devze.com 2023-03-24 18:15 出处:网络
In CRM 4.0. In the plugin i extracted ICrmService from the context and created a function that the ICrmService is passed as a parameter.

In CRM 4.0. In the plugin i extracted ICrmService from the context and created a function that the ICrmService is passed as a parameter. I also created a console application that creates a CRMService, i want to pass the CRMService to the above function but the function expect ICrmService not 开发者_JAVA技巧CRMService.

what do i do in this situation?

(the function is inside a dll that both the Plugin and the console application can use).


This is quite simple. You have to create a wrapper for the CrmService class, which implements ICrmService.

public class CrmServiceWrapper : ICrmService
{
    private bool _disposed;
    private readonly CrmService _service;

    public CrmServiceWrapper(CrmService service)
    {
        _service = service;
    }

    public Guid Create(BusinessEntity entity)
    {
        return _service.Create(entity);            
    }

    ...
}

Now you could wrap an instance of CrmService with this class and pass it to your method.

0

精彩评论

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

关注公众号