public static object CreateClient(ServiceConfigurations.ServiceName serviceName) { var serviceConf = ServiceConfigurations.ServiceConfigMapping[serviceName];; if (serviceConf == null) { throw new Exception("Tried to create a client to a not yet known Service"); } var binding = new WSHttpBinding(); var endpoint = new EndpointAddress(serviceConf.HttpBaseAddress); if (serviceName == ServiceConfigurations.ServiceName.OrderService) { return(new ChannelFactory <IOrderService>(binding, endpoint).CreateChannel()); } if (serviceName == ServiceConfigurations.ServiceName.ProductionService) { return(new ChannelFactory <IProductionService>(binding, endpoint).CreateChannel()); } return(null); }
private void RegisterMeAsListener(ServiceConfigurations.ServiceName otherServiceName, Type eventType) { var otherService = ServiceConfigurations.CreateEventingClient(otherServiceName); var eventName = WcfEvents.GetEventName(eventType); var thisServiceEnum = ServiceConfigurations.ParseServiceName(GetType()); otherService.RegisterListener(eventName, thisServiceEnum); }
public void RegisterListener(WcfEvents.EventName eventName, ServiceConfigurations.ServiceName listenerName) { Console.WriteLine("{0}: listens to: [{2}] and [{1}Event]", listenerName, eventName, GetType().Name); var eventType = WcfEvents.GetEventType(eventName); if (!eventType.IsSubclassOf(typeof(BaseEvent))) { throw new Exception("Invalid event registration"); } if (!ListenerIds.ContainsKey(eventName)) { ListenerIds[eventName] = new List <ServiceConfigurations.ServiceName> { listenerName }; return; } ListenerIds[eventName].Add(listenerName); }
protected void ListenTo <TEvent>( ServiceConfigurations.ServiceName otherServiceName, Action <BaseEvent> handlingMethod) where TEvent : BaseEvent { var eventType = typeof(TEvent); RegisterMeAsListener(otherServiceName, eventType); List <Action <BaseEvent> > handlerList; if (!_handlerActions.ContainsKey(eventType)) { handlerList = new List <Action <BaseEvent> >(); _handlerActions[eventType] = handlerList; } else { handlerList = _handlerActions[eventType]; } handlerList.Add(handlingMethod); }