00001 using System;
00002 using System.Collections.Generic;
00003 using System.Linq;
00004 using System.Text;
00005 using System.ServiceModel;
00006 using System.ServiceModel.Description;
00007 using System.ServiceModel.Channels;
00008 using System.Xml;
00009
00010 namespace UtmConvert {
00011 class IpcService {
00012
00013 public delegate void updateErrorEventHandler(Exception error);
00014 public event updateErrorEventHandler updateErrorEvent;
00015
00016 ServiceHost serviceHost;
00017 string _status = "ok";
00018 ~IpcService() {
00019 serviceHost.Close();
00020 }
00021
00022 public IpcService() {
00023 Uri baseAddress = new Uri("http://localhost/UtmConvert/UtmConvertService");
00024 string address = "net.pipe://localhost/UtmConvert/UtmConvertService";
00025 serviceHost = new ServiceHost(typeof(UtmConvertService), baseAddress);
00026 try {
00027
00028 NetNamedPipeBinding binding = new NetNamedPipeBinding(NetNamedPipeSecurityMode.None);
00029 serviceHost.AddServiceEndpoint(typeof(IUtmConvertService), binding, address);
00030
00031
00032 ServiceMetadataBehavior smb = new ServiceMetadataBehavior();
00033 smb.HttpGetEnabled = true;
00034 smb.HttpGetUrl = new Uri("http://localhost:8001/UtmConvert");
00035 serviceHost.Description.Behaviors.Add(smb);
00036 long maxBufferPoolSize = binding.MaxBufferPoolSize;
00037 int maxBufferSize = binding.MaxBufferSize;
00038 int maxConnections = binding.MaxConnections;
00039 long maxReceivedMessageSize = binding.MaxReceivedMessageSize;
00040 NetNamedPipeSecurity security = binding.Security;
00041 string scheme = binding.Scheme;
00042 XmlDictionaryReaderQuotas readerQuotas = binding.ReaderQuotas;
00043 BindingElementCollection bCollection = binding.CreateBindingElements();
00044 HostNameComparisonMode hostNameComparisonMode = binding.HostNameComparisonMode;
00045 bool TransactionFlow = binding.TransactionFlow;
00046 TransactionProtocol transactionProtocol = binding.TransactionProtocol;
00047 EnvelopeVersion envelopeVersion = binding.EnvelopeVersion;
00048 TransferMode transferMode = binding.TransferMode;
00049 serviceHost.Open();
00050 } catch (CommunicationException ce) {
00051 if (updateErrorEvent != null)
00052 updateErrorEvent.Invoke(ce);
00053 _status = ce.Message;
00054 serviceHost.Abort();
00055 }
00056 }
00057
00058
00059 }
00060 }