Created
February 23, 2017 17:05
-
-
Save rahulsahay19/4be2d7de526b76d13226748c983aaa6f to your computer and use it in GitHub Desktop.
MainWindow
This file contains 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
using System; | |
using System.Collections.Generic; | |
using System.ServiceModel; | |
using System.ServiceModel.Channels; | |
using System.Windows; | |
using MovieLib.Client.Contracts; | |
using MovieLib.Contracts; | |
using MovieLib.Proxies; | |
namespace MovieLib.Client | |
{ | |
/// <summary> | |
/// Interaction logic for MainWindow.xaml | |
/// </summary> | |
public partial class MainWindow : Window | |
{ | |
public MainWindow() | |
{ | |
InitializeComponent(); | |
} | |
private void Button_Click(object sender, RoutedEventArgs e) | |
{ | |
MovieClient proxyClient = new MovieClient("1stEP"); | |
try | |
{ | |
IEnumerable<MovieData> data = proxyClient.GetDirectorNames(); | |
if (data != null) | |
{ | |
LstDirectors.ItemsSource = data; | |
} | |
proxyClient.Close(); | |
} | |
catch (Exception ex) | |
{ | |
MessageBox.Show("Exception thrown by service." + ex); | |
} | |
} | |
private void Button_Click_1(object sender, RoutedEventArgs e) | |
{ | |
EndpointAddress address = new EndpointAddress("net.tcp://localhost:8010/MovieService"); | |
Binding binding = new NetTcpBinding(); | |
MovieClient proxyClient = new MovieClient(binding, address); | |
IEnumerable<MovieData> data = proxyClient.GetDirectorNames(); | |
if (data != null) | |
{ | |
LstDirectors.ItemsSource = data; | |
} | |
proxyClient.Close(); | |
} | |
private void btnInvoke_Click(object sender, RoutedEventArgs e) | |
{ | |
ChannelFactory<IMovieName> factory = new ChannelFactory<IMovieName>(""); | |
IMovieName proxyMovieName = factory.CreateChannel(); | |
proxyMovieName.SelectedMovie(txtMovieName.Text); | |
factory.Close(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment