Exemple #1
0
        public static void ReportAsWarning(this IWarningsService warningsService, Task <Exception> potentiallyFailingTask, string prefix = "Warning: ")
        {
            if (warningsService == null)
            {
                throw new ArgumentNullException(nameof(warningsService));
            }
            if (potentiallyFailingTask == null)
            {
                throw new ArgumentNullException(nameof(potentiallyFailingTask));
            }
            if (prefix == null)
            {
                throw new ArgumentNullException(nameof(prefix));
            }

            potentiallyFailingTask.ContinueWith(t => {
                if (t.IsFaulted)
                {
                    warningsService.ReportAsWarning(t.Exception, prefix);
                }
                if (t.IsCompleted)
                {
                    warningsService.ReportAsWarning(t.Result, prefix);
                }
            }, TaskScheduler.Default);
        }
Exemple #2
0
        public MainDialog(TicketBookingRecognizer recognizer, BookingDialog bookingDialog, ICinemaService cinemaService,
                          IWarningsService warningsService, ITranslationService translationService, UserState userState) : base(nameof(MainDialog))
        {
            luisRecognizer          = recognizer;
            this.cinemaService      = cinemaService;
            this.warningsService    = warningsService;
            this.translationService = translationService;
            languageStateProperty   = userState.CreateProperty <string>("LanguagePreference");
            needToTranslateProperty = userState.CreateProperty <bool>("NeedToTranslate");

            AddDialog(new TextPrompt(nameof(TextPrompt)));
            AddDialog(bookingDialog);
            AddDialog(new WaterfallDialog(nameof(WaterfallDialog), new WaterfallStep[]
            {
                IntroStepAsync,
                ActStepAsync,
                FinalStepAsync,
            }));

            InitialDialogId = nameof(WaterfallDialog);
        }
Exemple #3
0
        public static void ReportAsWarning(this IWarningsService warningsService, Exception exception, string prefix = "Warning: ")
        {
            if (warningsService == null)
            {
                throw new ArgumentNullException(nameof(warningsService));
            }
            if (exception == null)
            {
                throw new ArgumentNullException(nameof(exception));
            }
            if (prefix == null)
            {
                throw new ArgumentNullException(nameof(prefix));
            }

            string message = prefix + exception.Message;

            warningsService.Warn(exception, message, properties: new SortedDictionary <string, object?> {
                [nameof(exception.StackTrace)]     = exception.StackTrace,
                [nameof(exception.Source)]         = exception.Source,
                [nameof(exception.HResult)]        = exception.HResult,
                [nameof(exception.InnerException)] = exception.InnerException?.ToString(),
            });
        }