public static void ReportAndDisplay(this Exception ex)
        {
            New <IReport>().Exception(ex);
            AxCryptException aex = ex as AxCryptException;

            if (aex != null)
            {
                New <IStatusChecker>().CheckStatusAndShowMessage(aex.ErrorStatus, aex.DisplayContext, aex.Message);
                return;
            }
            New <IStatusChecker>().CheckStatusAndShowMessage(ErrorStatus.Exception, ex?.Message ?? "(null)", Texts.Exception.InvariantFormat("unknown"));
        }
        public static void RethrowFileOperation(this Exception ex, string displayContext)
        {
            if (ex == null)
            {
                throw new ArgumentNullException(nameof(ex));
            }

            AxCryptException aex = ex as AxCryptException;

            if (aex != null)
            {
                throw new FileOperationException(aex.Message, displayContext, aex.ErrorStatus, ex);
            }
            throw new FileOperationException(ex.Message, displayContext, ErrorStatus.Exception, ex);
        }
        private async Task InvokeAsync <T>(IEnumerable <T> files, Func <T, IProgressContext, Task <FileOperationContext> > workAsync, Func <FileOperationContext, Task> allCompleteAsync)
        {
            WorkerGroupProgressContext groupProgress = new WorkerGroupProgressContext(new CancelProgressContext(new ProgressContext()), New <ISingleThread>());

            await New <IProgressBackground>().WorkAsync(nameof(DoFilesAsync),
                                                        async(IProgressContext progress) =>
            {
                progress.NotifyLevelStart();

                FileOperationContext result = await Task.Run(async() =>
                {
                    FileOperationContext context = null;

                    foreach (T file in files)
                    {
                        try
                        {
                            context = await workAsync(file, progress);
                        }
                        catch (Exception ex) when(ex is OperationCanceledException)
                        {
                            return(new FileOperationContext(file.ToString(), ErrorStatus.Canceled));
                        }
                        catch (Exception ex) when(ex is AxCryptException)
                        {
                            AxCryptException ace = ex as AxCryptException;
                            New <IReport>().Exception(ace);
                            return(new FileOperationContext(ace.DisplayContext.Default(file), ace.InnerException?.Message ?? ace.Message, ace.ErrorStatus));
                        }
                        catch (Exception ex)
                        {
                            New <IReport>().Exception(ex);
                            return(new FileOperationContext(file.ToString(), ex.Message, ErrorStatus.Exception));
                        }
                        if (context.ErrorStatus != ErrorStatus.Success)
                        {
                            return(context);
                        }
                        progress.Totals.AddFileCount(1);
                    }
                    return(new FileOperationContext(progress.Totals));
                });
                progress.NotifyLevelFinished();
                return(result);
            },
                                                        (FileOperationContext status) => allCompleteAsync(status),
                                                        groupProgress).Free();
        }