【发布时间】:2012-03-29 05:50:35
【问题描述】:
这就是我以前进行方法调用的方式:
SvcHelper.Using<SomeWebServiceClient>(proxy =>
{
proxy.SomeMethod();
}
public class SvcHelper
{
public static void Using<TClient>(Action<TClient> action) where TClient : ICommunicationObject, IDisposable, new()
{
}
}
这就是我进行方法调用的方式:
ChannelFactory<ISomethingWebService> cnFactory = new ChannelFactory<ISomethingWebService>("SomethingWebService");
ISomethingWebService client = cnFactory.CreateChannel();
using (new OperationContextScope((IContextChannel)client))
{
client.SomeMethod();
}
我的问题是:而不是替换我原来的方法调用方法的每个实例;有没有办法修改我的SvcHelper 并在SvcHelper 构造函数中创建通道,然后简单地传递如下接口:
SvcHelper.Using<ISomethingWebService>(client =>
{
client.SomeMethod();
}
希望这是有道理的,并在此先感谢。
【问题讨论】:
标签: c# asp.net wcf entity-framework