當前位置: 首頁>>代碼示例>>C#>>正文


C# AggregateException.Flatten方法代碼示例

本文整理匯總了C#中System.AggregateException.Flatten方法的典型用法代碼示例。如果您正苦於以下問題:C# AggregateException.Flatten方法的具體用法?C# AggregateException.Flatten怎麽用?C# AggregateException.Flatten使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.AggregateException的用法示例。


在下文中一共展示了AggregateException.Flatten方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: concatMessages

 private static String concatMessages(AggregateException ae)
 {
     if (ae == null)
     {
         return "";
     }
     var flattened = ae.Flatten();
     return String.Join("\n\n", from exc in flattened.InnerExceptions
         select getExceptionMessages("", exc));
 }
開發者ID:xebialabs-community,項目名稱:xld-manifest-editor,代碼行數:10,代碼來源:DeployitServerConnectionException.cs

示例2: GetAggrateException

        internal static string GetAggrateException(AggregateException ex)
        {
            StringBuilder sb = new StringBuilder();
            sb.AppendLine(string.Join("  ",
                    ex.Message,
                    ex.StackTrace));

            foreach (var innerEx in ex.Flatten().InnerExceptions)
            {
                sb.AppendLine(GetExceptionString(ex));
            }
            return sb.ToString();
        }
開發者ID:haiyangIt,項目名稱:Haiyang,代碼行數:13,代碼來源:LogWriter.cs

示例3: ParseExceptionMessage

 private static void ParseExceptionMessage(StringBuilder sb, AggregateException aex)
 {
     if (aex != null)
     {
         ParseCommonExceptionMessage(sb, aex);
         sb.AppendLine();
         sb.AppendLine();
         sb.AppendLine("InnerExceptions :");
         sb.Append("===============================");
         aex.Flatten().Handle((ex) =>
         {
             ParseAllExceptionMessage(sb, ex);
             sb.AppendLine();
             return true;
         });
     }
 }
開發者ID:deboe2015,項目名稱:Ctrip.SOA,代碼行數:17,代碼來源:ExceptionHelper.cs

示例4: FinishRebuildAll

        public void FinishRebuildAll(TaskStatus status, AggregateException exception)
        {
            _writeline($"Finished RebuildAll with status {status}");
            if (exception != null)
            {
                var flattened = exception.Flatten();

                foreach (var ex in flattened.InnerExceptions)
                {
                    _writeline("");
                    _writeline("---------");
                    _writeline("Exception:");
                    _writeline("---------");
                    _writeline(ex.ToString());
                    _writeline("");
                }
            }
        }
開發者ID:danielmarbach,項目名稱:marten,代碼行數:18,代碼來源:TracingLogger.cs

示例5: AddProblem

        public NugetProblem AddProblem(AggregateException aggregate)
        {
            var message = "Fatal error";
            Exception exception = aggregate;
            if (aggregate != null)
            {
                exception = aggregate.Flatten();
                message = exception.Message;

                if (exception.InnerException != null)
                {
                    exception = exception.InnerException;
                    message = exception.Message;
                }
            }

            var problem = new NugetProblem(message, exception);
            AddProblem(problem);

            return problem;
        }
開發者ID:modulexcite,項目名稱:ripple,代碼行數:21,代碼來源:NugetResult.cs

示例6: Flatten

        public static void Flatten()
        {
            Exception exceptionA = new Exception("A");
            Exception exceptionB = new Exception("B");
            Exception exceptionC = new Exception("C");

            AggregateException aggExceptionBase = new AggregateException(exceptionA, exceptionB, exceptionC);

            // Verify flattening one with another.
            // > Flattening (no recursion)...

            AggregateException flattened1 = aggExceptionBase.Flatten();
            Exception[] expected1 = new Exception[] {
                exceptionA, exceptionB, exceptionC
            };

            Assert.Equal(expected1, flattened1.InnerExceptions);

            // Verify flattening one with another, accounting for recursion.
            AggregateException aggExceptionRecurse = new AggregateException(aggExceptionBase, aggExceptionBase);
            AggregateException flattened2 = aggExceptionRecurse.Flatten();
            Exception[] expected2 = new Exception[] {
                exceptionA, exceptionB, exceptionC, exceptionA, exceptionB, exceptionC,
            };

            Assert.Equal(expected2, flattened2.InnerExceptions);
        }
開發者ID:noahfalk,項目名稱:corefx,代碼行數:27,代碼來源:AggregateExceptionTests.cs

示例7: FileErrored

 private void FileErrored(ProcessingFile processingFile, AggregateException exception)
 {
     Logger.Error(string.Format("File processing failed: {0}", processingFile.OriginalFilePath), exception.Flatten());
     this.processResultHandler.Handle(FileProcessResult.Error, processingFile);
 }
開發者ID:RustyF,項目名稱:EnergyTrading-Core,代碼行數:5,代碼來源:FileProducerConsumerQueue.cs

示例8: FindException

        static Exception FindException(AggregateException exception) {
            foreach (var e in exception.Flatten().InnerExceptions) {
                if (e is Win32Exception)
                    return e;

                var ce = e as CompositionException;
                if (ce != null) {
                    var found = FindException(ce);
                    if (found != null)
                        return found;
                }

                if (!(e is XamlException))
                    continue;

                var inner = e.FindInnerException<Win32Exception>();
                if (inner != null)
                    return inner;
            }
            return null;
        }
開發者ID:MaHuJa,項目名稱:withSIX.Desktop,代碼行數:21,代碼來源:PlayShellView.xaml.cs

示例9: PrintAggregateException

 /// <summary>
 /// Processes all exceptions inside an <see cref="AggregateException"/> and writes each inner exception to the console.
 /// </summary>
 /// <param name="aggregateException">The <see cref="AggregateException"/> to process.</param>
 public static void PrintAggregateException(AggregateException aggregateException)
 {
     // Flatten the aggregate and iterate over its inner exceptions, printing each
     foreach (Exception exception in aggregateException.Flatten().InnerExceptions)
     {
         Console.WriteLine(exception.ToString());
         Console.WriteLine();
     }
 }
開發者ID:paselem,項目名稱:azure-batch-samples,代碼行數:13,代碼來源:Program.cs

示例10: DumpException

        private static void DumpException(AggregateException ex, StreamWriter sw, string header)
        {
            AggregateException flat = ex.Flatten();
            
            if (header != null)
            {
                sw.WriteLine("Custom header message:");
                sw.WriteLine(header);
                sw.WriteLine("---");
            }

            sw.WriteLine("Aggregate Exception: " + ex.Message);
            sw.WriteLine("---");

            foreach (Exception eo in ex.InnerExceptions)
            {
                DumpException(eo, sw, null);
            }
        }
開發者ID:WFoundation,項目名稱:WF.Player.WinPhone,代碼行數:19,代碼來源:DebugUtils.cs

示例11: HandleException

 /// <summary>
 /// Exception handler for the connection class
 /// </summary>
 /// <param name="exception"></param>
 public static void HandleException(AggregateException exception)
 {
     if (exception == null) return;
     foreach (var ex in exception.Flatten().InnerExceptions)
     {
         Log(ex.StackTrace);
     }
 }
開發者ID:Citidel,項目名稱:edgebot,代碼行數:12,代碼來源:Utils.cs


注:本文中的System.AggregateException.Flatten方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。