{
public delegate void ServiceProxyDelegate
public ServiceProxy()
: base(typeof(TInterface).ToString())
{
}
public ServiceProxy(string endpointConfigurationName)
: base(endpointConfigurationName)
{
}
protected override TInterface CreateChannel()
{
return base.CreateChannel();
}
public TInterface Proxy
{
get
{
return this.Channel;
}
}
public static void Call(ServiceProxyDelegate
{
Call(proxyDelegate, typeof(TInterface).ToString());
}
public static void Call(ServiceProxyDelegate
{
ChannelFactory
try
{
proxyDelegate(channel.CreateChannel());
}
finally
{
if (channel.State == CommunicationState.Faulted)
{
channel.Abort();
}
else
{
try
{
channel.Close();
}
catch
{
channel.Abort();
}
}
}
}
public void Dispose()
{
if (this.State == CommunicationState.Faulted)
{
base.Abort();
}
else
{
try
{
base.Close();
}
catch
{
base.Abort();
}
}
}
}
And, here are some usages samples...
//delegate example1
string response = null;
ServiceModel.ServiceProxy
{
response = p.DoStuff("ServiceProxyUsingTest");
}
);
//delegate example2
string response = null;
ServiceProxy
//using example
string response = null;
using (ServiceProxy
{
response = service.Proxy.DoStuff("ServiceProxyUsingTest");
}
Ref:http://blog.weminuche.net/2008/08/test-post.html
http://www.idesign.net/idesign/DesktopDefault.aspx?tabindex=5&tabid=11#WCFContracts
http://www.dofactory.com/ShortCutKeys/ShortCutKeys.aspx
http://my.safaribooksonline.com/0130925691
No comments:
Post a Comment