From 69d06f5cde6d9e5fa0a380e4b666fccbac5375da Mon Sep 17 00:00:00 2001 From: Tichau Date: Mon, 7 Dec 2015 18:50:39 +0100 Subject: [PATCH] Fixed: Debug are now updated when a new DiagnosticsData is created. --- .../FileConverter/Diagnostics/Debug.cs | 35 ++++--------------- 1 file changed, 6 insertions(+), 29 deletions(-) diff --git a/Application/FileConverter/Diagnostics/Debug.cs b/Application/FileConverter/Diagnostics/Debug.cs index d14b155..e3c0954 100644 --- a/Application/FileConverter/Diagnostics/Debug.cs +++ b/Application/FileConverter/Diagnostics/Debug.cs @@ -1,5 +1,7 @@ // License: http://www.gnu.org/licenses/gpl.html GPL version 3. +using System.Linq; + namespace FileConverter.Diagnostics { using System; @@ -12,7 +14,6 @@ namespace FileConverter.Diagnostics public static class Debug { - private static StringBuilder workingStringBuilder = new StringBuilder(); private static string diagnosticsFolderPath; private static Dictionary diagnosticsDataById = new Dictionary(); private static int threadCount = 0; @@ -41,32 +42,11 @@ namespace FileConverter.Diagnostics Directory.CreateDirectory(Debug.diagnosticsFolderPath); } - public static IEnumerable Data + public static DiagnosticsData[] Data { get { - return Debug.diagnosticsDataById.Values; - } - } - - public static string Content - { - get - { - DiagnosticsData diagnosticsData; - int threadId = System.Threading.Thread.CurrentThread.ManagedThreadId; - if (!Debug.diagnosticsDataById.TryGetValue(threadId, out diagnosticsData)) - { - return string.Empty; - } - - workingStringBuilder.Clear(); - foreach (string logMessage in diagnosticsData.LogMessages) - { - workingStringBuilder.AppendLine(logMessage); - } - - return workingStringBuilder.ToString(); + return Debug.diagnosticsDataById.Values.ToArray(); } } @@ -83,15 +63,12 @@ namespace FileConverter.Diagnostics diagnosticsData.Initialize(Debug.diagnosticsFolderPath, threadId); Debug.diagnosticsDataById.Add(threadId, diagnosticsData); Debug.threadCount++; + + StaticPropertyChanged?.Invoke(null, new PropertyChangedEventArgs("Data")); } } diagnosticsData.Log(message, arguments); - - if (StaticPropertyChanged != null) - { - StaticPropertyChanged(null, new PropertyChangedEventArgs("Content")); - } } public static void LogError(string message, params object[] arguments)