Ejemplo n.º 1
0
            //--
            //-- display a dialog to the user; otherwise we just terminate with no alert at all!
            //--

            private static void ExceptionToUI()
            {
                const string _strWhatHappened    = "There was an unexpected error in (app). This may be due to a programming bug.";
                string       _strHowUserAffected = null;
                const string _strWhatUserCanDo   = "Restart (app), and try repeating your last action. Try alternative methods of performing the same action.";

                if (ExceptionManager.Settings.KillAppOnException)
                {
                    _strHowUserAffected = "When you click OK, (app) will close.";
                }
                else
                {
                    _strHowUserAffected = "The action you requested was not performed.";
                }

                if (!_blnConsoleApp)
                {
                    //-- don't send ANOTHER email if we are already doing so!
                    Handled.IsErrorToBeEmailed = !Settings.SendEmail;
                    //-- pop the dialog
                    Handled.ShowDialog(_strWhatHappened, _strHowUserAffected, _strWhatUserCanDo, FormatExceptionForUser(false), null, MessageBoxButtons.OK, MessageBoxIcon.Stop);
                }
                else
                {
                    //-- note that writing to console pauses for ENTER
                    //-- otherwise console window just terminates immediately
                    ExceptionToConsole();
                }
            }
Ejemplo n.º 2
0
 // Events appling
 internal void ApplyEvent(Event @event)
 {
     Applying?.Invoke(this, new EventArgs <Event>(@event));
     Validate(@event);
     Validated?.Invoke(this, new EventArgs <Event>(@event));
     Handle(@event);
     Handled?.Invoke(this, new EventArgs <Event>(@event));
     pendingEvents.Push(@event);
     Pendent?.Invoke(this, new EventArgs <Event>(@event));
 }
        public void SerializeResponse_should_assume_status_code_200_for_non_IHttpResponseResult()
        {
            // Given an HttpContext
            HttpContext httpContext = new DefaultHttpContext();

            httpContext.Request.ContentType = "application/json";

            // And a Handled result
            IHandlerResult handlerResult = new Handled();

            // When I try to write the response out to the http context
            ResponseWriter responseWriter = new ResponseWriter(httpContext, OutputFormatter);

            responseWriter.SerializeResponseAsync(handlerResult).Wait();


            // Then the status code of the HttpReponse should be set correctly
            httpContext.Response.StatusCode.Should().Be((int)HttpStatusCode.OK);
        }
Ejemplo n.º 4
0
 protected virtual void OnHandled(DeltaFileTransaction transaction)
 {
     Handled?.Invoke(this, transaction);
 }
Ejemplo n.º 5
0
 public Task Handle(OutOfBandNotification notification, CancellationToken cancellationToken)
 {
     Handled?.Invoke(this, notification);
     return(Task.CompletedTask);
 }
Ejemplo n.º 6
0
 public Task <Unit> Handle(OutOfBandCommand request, CancellationToken cancellationToken)
 {
     Handled?.Invoke(this, request);
     return(Unit.Task);
 }