protected virtual void SendRoutedEventMessage(RoutedEventBase routedEvent, object sender, RoutedEventArgs args, RaiseScope raiseScope = null) { var message = new RoutedEventMessage(routedEvent, CreateCurrentApplicationSender(sender), args); RoutedEventMessageBus.Send(message, raiseScope); }
protected virtual void Publish(RoutedEventMessage message, RaiseScope raiseScope = null) { using (IPublishChannel channel = MessageBus.OpenPublishChannel()) { var messageProperties = new MessageProperties() { DeliveryMode = 2 }; var body = Serializer.MessageToBytes(message); channel.Publish(RoutedEventExchange, GetRoutingKey(raiseScope), messageProperties, body); } }
private string GetRoutingKey(RaiseScope raiseScope = null) { if (raiseScope == null) { return(AllAppScopeRoutingKey); } if (raiseScope is AppIdRasieScope) { return(GetAppIdScopeRoutingKey((raiseScope as AppIdRasieScope).ApplicationId)); } if (raiseScope is AppTypeRasieScope) { return(GetAppTypeScopeRoutingKey((raiseScope as AppTypeRasieScope).ApplicationType)); } if (raiseScope is AppGroupRasieScope) { return(GetAppTypeScopeRoutingKey((raiseScope as AppGroupRasieScope).ApplicationGroup)); } throw new NotImplementedException(string.Format("暂不支持{0}类型的事件范围", raiseScope.GetType().FullName)); }
public void Send(RoutedEventMessage message, RaiseScope raiseScope = null) { Preconditions.CheckNotNull(message, "message"); Publish(message, raiseScope); }
private string GetRoutingKey(RaiseScope raiseScope = null) { if (raiseScope == null) { return AllAppScopeRoutingKey; } if (raiseScope is AppIdRasieScope) { return GetAppIdScopeRoutingKey((raiseScope as AppIdRasieScope).ApplicationId); } if (raiseScope is AppTypeRasieScope) { return GetAppTypeScopeRoutingKey((raiseScope as AppTypeRasieScope).ApplicationType); } if (raiseScope is AppGroupRasieScope) { return GetAppTypeScopeRoutingKey((raiseScope as AppGroupRasieScope).ApplicationGroup); } throw new NotImplementedException(string.Format("暂不支持{0}类型的事件范围", raiseScope.GetType().FullName)); }
public void Raise <T>(RoutedEvent <T> routedEvent, object sender, T args, RaiseScope scope) where T : RoutedEventArgs { SendRoutedEventMessage(routedEvent, sender, args, scope); }
public void Raise(RoutedEvent routedEvent, object sender, RoutedEventArgs args, RaiseScope scope) { SendRoutedEventMessage(routedEvent, sender, args, scope); }