public async Task <string> GetConvertedWordAsync(string inputNumber) { // Create a channel factory. var binding = new BasicHttpBinding(); var endpoint = new EndpointAddress(this._wcfServiceUri); var channelFactory = new ChannelFactory <IConvertorService>(binding, endpoint); // Create a channel IConvertorService wcfClient = channelFactory.CreateChannel(); try { return(await wcfClient.ConvertNumberToWordAsync(inputNumber)); } catch (EndpointNotFoundException) { throw new Exception(Constant.Exception_ConnectionFailed); } catch (CommunicationException ex) { if (ex.GetBaseException() is SocketException) { throw new Exception(Constant.Exception_ConnectionFailed); } throw; } catch (Exception ex) { throw new Exception(Constant.Exception_HasError); } finally { ((IClientChannel)wcfClient).Close(); channelFactory.Close(); } }
public MainWindow(IConvertorService convertorService) { InitializeComponent(); DataContext = new TestYodoConvertor.ViewModels.YodoSpeakViewModel(convertorService); }
public YodoSpeakViewModel(IConvertorService ConvertService) { YodoSpeak = new YodoSpeak("Convert to Yodo speak."); this.ConvertService = ConvertService; ConvertCommand = new YodoSpeakConvertCommand(this); }