Skip to content

Instantly share code, notes, and snippets.

@rahulsahay19
Created February 23, 2017 17:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rahulsahay19/4be2d7de526b76d13226748c983aaa6f to your computer and use it in GitHub Desktop.
Save rahulsahay19/4be2d7de526b76d13226748c983aaa6f to your computer and use it in GitHub Desktop.
MainWindow
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