private void Resolve(ResolveRequestDTO req) { Entity <DataType> .ResolveStarted(req); this.resolver.Resolve(req, (r => { if (ResolveErrorHelper.HandledError(req.key, r, Entity <DataType> .RESOLVE_FAILED, debug: this.debug)) { return; } var resultItem = r.item; if (!this.isOkStatus(resultItem.status)) { NotificationBus.Send( Entity <DataType> .RESOLVE_FAILED, ResolveFailedDTO.For(req, resultItem.status) ); return; } Entity <DataType> .ResolveSucceeded( new ResolveSucceededDTO <DataType> { key = req.key, id = resultItem.id, resolveRequestId = req.resolveRequestId, data = resultItem.data, timestamp = resultItem.timestamp, maxAgeSecs = resultItem.maxAgeSecs }); })); }
public static void Close <T>(bool showLast = false) { NotificationBus.SendWBody <ClosePanel>(CLOSE, new ClosePanel { panelType = typeof(T), showLast = showLast }); }
public NotificationBusTests() { notificationChannel1 = Substitute.For <INotificationChannel>(); notificationChannel1.NotificationTypes.Returns(new[] { typeof(Notification1) }); notificationChannel2 = Substitute.For <INotificationChannel>(); notificationChannel2.NotificationTypes.Returns(new[] { typeof(Notification2) }); sut = new NotificationBus(new[] { notificationChannel1, notificationChannel2 }); }
public static void Close(object panel = null, bool showLast = false) { var go = panel as GameObject ?? (panel as Component != null) ? (panel as Component).gameObject : null; NotificationBus.SendWBody <ClosePanel>(CLOSE, new ClosePanel { panelGO = go, showLast = showLast }); }
public static bool HandledError(HasError r, string errorNotification, bool debug = false) { if (string.IsNullOrEmpty(r.error)) { return(false); } #if UNITY_EDITOR || DEBUG_UNSTRIP Debug.LogWarning("[" + Time.frameCount + "] error loading : " + r.error); #endif NotificationBus.Send(errorNotification, new ResolveFailedDTO { error = r }); return(true); }
private async void Resolve(ResolveRequestDTO req) { #if UNITY_EDITOR || DEBUG_UNSTRIP if (this.debug) { Debug.LogFormat( "[{0}] will resolve {1} with key {2}", Time.frameCount, typeof(DataType).Name, req.key ); } #endif Entity <DataType> .ResolveStarted(req); try { var resultItem = await this.resolver.ResolveAsync(req); if (!this.isOkStatus(resultItem.status)) { NotificationBus.Send( Entity <DataType> .RESOLVE_FAILED, ResolveFailedDTO.For(req, resultItem.status) ); return; } Entity <DataType> .ResolveSucceeded( new ResolveSucceededDTO <DataType> { key = req.key, id = resultItem.id, resolveRequestId = req.resolveRequestId, data = resultItem.data, timestamp = resultItem.timestamp, maxAgeSecs = resultItem.maxAgeSecs }); } catch (Exception e) { Entity <DataType> .ResolveFailed( ResolveFailedDTO.For(req, e.Message) ); } }
public static ResolveAdvice AdviseOnAndSendErrorIfCoolingDown( HasStateResolveStatus hasLoadStatus, string errorNotification, float loadTimeoutSecs = DEFAULT_LOAD_TIMEOUT_SECS, float retryMinIntervalSecs = DEFAULT_RETRY_MIN_INTERVAL_SECS, float ttlSecs = DEFAULT_TTL_SECS, bool debug = false) { var advice = AdviseOn(hasLoadStatus, loadTimeoutSecs, retryMinIntervalSecs, ttlSecs, debug); if (advice == ResolveAdvice.CANCEL_ERROR_COOL_DOWN) { NotificationBus.Send(errorNotification, new ResolveFailedDTO { error = "load has failed for id and is in cooldown period" }); } return(advice); }
public static ResolveAdvice AdviseOnAndSendErrorIfCoolingDown( string id, HasEntityResolveStatus hasData, string errorNotification, float resolveTimeoutSecs = DEFAULT_RESOLVE_TIMEOUT_SECS, float retryMinIntervalSecs = DEFAULT_RETRY_MIN_INTERVAL_SECS, bool debug = false) { var advice = AdviseOn(id, hasData, resolveTimeoutSecs, retryMinIntervalSecs, debug); if (advice == ResolveAdvice.CANCEL_ERROR_COOL_DOWN) { NotificationBus.Send(errorNotification, new ResolveFailedDTO { key = id, error = "resolve has failed for id and is in cooldown period" }); } return(advice); }
public MainWindow() { InitializeComponent(); var bus = new NotificationBus(); DataContext = new MainViewModel(bus); var systemEvents = BackupEventTypeCreator.CreateFromSystemEvents(bus); systemEvents = Observable.Timer(TimeSpan.Zero, TimeSpan.FromMinutes(1)) .Select(_ => BackupAndRestorePosition.EventType.Backup) .Merge(systemEvents); var collector = new PositionWindowsByProcessCollector(); var excludedProcesses = LoadExcludedProcesses(); _backupAndRestorePosition = new BackupAndRestorePosition(systemEvents, collector, new PostionRestoreOperator(bus), excludedProcesses, bus); }
public void Send_Notification_Success(int notificationCount) { //Assemble var sentNotifications = new List <Notification>(); var senderMock = new Mock <INotificationSender>(); senderMock.Setup(s => s.SendAsync(It.IsAny <Notification>())) .Callback <Notification>(n => sentNotifications.Add(n)); var sut = new NotificationBus(senderMock.Object); //Act for (int i = 0; i < notificationCount; i++) { sut.Push(new Notification(string.Empty, string.Empty, string.Empty)); } //Assert Assert.Equal(notificationCount, sentNotifications.Count); }
public void Install(IWindsorContainer container, IConfigurationStore store) { var bus = new NotificationBus(container.Resolve<IServiceBus>()); container.Register(Component.For<INotificationBus>().Instance(bus).LifeStyle.Singleton); }
public void Install(IWindsorContainer container, IConfigurationStore store) { var bus = new NotificationBus(container.Resolve <IServiceBus>()); container.Register(Component.For <INotificationBus>().Instance(bus).LifeStyle.Singleton); }
public static void ActiveModalWindowChanged(ManagedPanel p, NotificationReceiverOptions opts = NotificationReceiverOptions.DontRequireReceiver) { NotificationBus.SendWBody <ManagedPanel>(ACTIVE_MODAL_WINDOW_CHANGED, p, opts); }
public static void CloseAll() { NotificationBus.Send(CLOSE_ALL); }
public static void Open(ChangePanel panelRequest) { NotificationBus.SendWBody <ChangePanel>(OPEN, panelRequest); }