private static readonly TimeSpan TimeToWaitBeforeClosing = new TimeSpan(0, 0, 6); // 6 seconds // We need only one channel, but the WCF protocol requires us to provide a factory... private static DuplexChannelFactory <IClousotService> GetChannelFactoryForType(Type type) { lock (LockChannelFactoryForType) { DuplexChannelFactory <IClousotService> channelFactory; if (channelFactoryForType.TryGetValue(type, out channelFactory)) { return(channelFactory); } #if EMBEDDED_CONFIGURATION channelFactory = new CustomDuplexChannelFactory <IClousotService>(configuration, type); #elif HARDCODED_CONFIGURATION var binding = ClousotWCFServiceCommon.NewBinding(ClousotWCFServiceCommon.SecurityMode); binding.ReceiveTimeout = TimeSpan.FromDays(2); binding.SendTimeout = TimeSpan.FromDays(2); var endpointAddress = new EndpointAddress(ClousotWCFServiceCommon.BaseUri, ClousotWCFServiceCommon.Identity); channelFactory = new DuplexChannelFactory <IClousotService>(type, binding, endpointAddress); #else channelFactory = new DuplexChannelFactory <IClousotService>(type); #endif channelFactoryForType.Add(type, channelFactory); return(channelFactory); } }
private void AddMainEndpoint(Uri baseUri) { Contract.Requires(baseUri != null); Contract.Requires(baseUri.IsAbsoluteUri); var contract = ContractDescription.GetContract(typeof(IClousotService), typeof(ClousotService)); var binding = ClousotWCFServiceCommon.NewBinding(ClousotWCFServiceCommon.SecurityMode); var identity = ClousotWCFServiceCommon.Identity; var address = new EndpointAddress(baseUri, identity); var endpoint = new ServiceEndpoint(contract, binding, address); // This is the point where we listen at this.AddServiceEndpoint(endpoint); }