ПКРПСиБД LAB1 Захаров А.Е. (548667), страница 2
Текст из файла (страница 2)
App.config
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"> maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" /> negotiateServiceCredential="true" algorithmSuite="Default" />
bindingConfiguration="WSDualHttpBinding_IStringCrypt" contract="Client.IStringCrypt" name="WSDualHttpBinding_IStringCrypt"/> Form1.cs using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.ServiceModel; namespace Client { public partial class ClientForm : Form { const int MD5 = 0; const int SHA1 = 1; const int SHA256 = 2; const int SHA512 = 3; StringCryptClient client; public class CallbackHandler : IStringCryptCallback { ClientForm form; public CallbackHandler(ClientForm form) { this.form = form; } public void count(int count) { form.infoLabel.Text = "Общее число клиентов " + count; } } public ClientForm() { InitializeComponent(); algComboBox.SelectedIndex = MD5; try { InstanceContext instanceContext = new InstanceContext(new CallbackHandler(this)); client = new StringCryptClient(instanceContext); client.join(); } catch (Exception e) { MessageBox.Show(e.Message); return; } } private void hashRefresh() { const string defaultText = ""; string str = strTextBox.Text; if (string.IsNullOrEmpty(str)) { hashTextBox.Text = defaultText; return; } string hash; try { switch (algComboBox.SelectedIndex) { case MD5: hash = client.md5(str); break; case SHA1: hash = client.sha1(str); break; case SHA256: hash = client.sha256(str); break; case SHA512: hash = client.sha512(str); break; default: hashTextBox.Text = defaultText; return; } } catch (Exception e) { MessageBox.Show(e.Message); hashTextBox.Text = defaultText; return; } hashTextBox.Text = hash; } private void strTextBox_TextChanged(object sender, EventArgs e) { hashRefresh(); } private void algComboBox_SelectedIndexChanged(object sender, EventArgs e) { hashRefresh(); } private void ClientForm_FormClosed(object sender, FormClosedEventArgs e) { client.leave(); client.Close(); } } } Основы Windows Communication Foundation для .NET Framework 3.5: Пер. с англ. Слинкина А. А. – М.: ДМК Пресс, 2008. – 480 с.: ил. Создание служб Windows Communication Foundation. Дж. Лёве. – Спб.: Питер, 2008. – 592 с.: ил.
Литература