Skip to content

Instantly share code, notes, and snippets.

@ajtowf
Last active August 29, 2015 14:15
Show Gist options
  • Save ajtowf/925e8e79a089bbedefbf to your computer and use it in GitHub Desktop.
Save ajtowf/925e8e79a089bbedefbf to your computer and use it in GitHub Desktop.
WcfAsyncProxyRefactor
var client = new ServiceClientAsync();
var data = await client.GetDataAsync(10);
[ServiceContract(Name = "IService1")]
interface IService1Async
{
[OperationContract]
Task<string> GetDataAsync(int value);
}
class ServiceClientAsync : IService1Async
{
private readonly IService1Async _channel;
public ServiceClientAsync()
{
var factory = new ChannelFactory<IService1Async>(binding, address);
_channel = factory.CreateChannel();
}
public Task<string> GetDataAsync(int value)
{
return _channel.GetDataAsync(value);
}
}
public class Service1 : IService1
{
public string GetData(int value)
{
return string.Format("You entered: {0}", value);
}
}
var client = new ServiceClient();
var data = client.GetData(10)
class ServiceClient : IService1
{
private readonly IService1 _channel;
public ServiceClient()
{
var factory = new ChannelFactory<IService1>(binding, address);
_channel = factory.CreateChannel();
}
public string GetData(int value)
{
return _channel.GetData(value);
}
}
[ServiceContract]
public interface IService1
{
[OperationContract]
string GetData(int value);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment