Last active
August 29, 2015 14:15
-
-
Save ajtowf/925e8e79a089bbedefbf to your computer and use it in GitHub Desktop.
WcfAsyncProxyRefactor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var client = new ServiceClientAsync(); | |
var data = await client.GetDataAsync(10); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ServiceContract(Name = "IService1")] | |
interface IService1Async | |
{ | |
[OperationContract] | |
Task<string> GetDataAsync(int value); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Service1 : IService1 | |
{ | |
public string GetData(int value) | |
{ | |
return string.Format("You entered: {0}", value); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var client = new ServiceClient(); | |
var data = client.GetData(10) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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