Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Pryor <jpryor@novell.com>2009-05-02 00:21:50 +0400
committerJonathan Pryor <jpryor@novell.com>2009-05-02 00:21:50 +0400
commitf80c179df7220a63c61f3ba8e31d6acf9c415c11 (patch)
treea094c509bc6b099933409ec1f0aba41c98df8e19 /mcs/class/System/System.Diagnostics/TraceImpl.cs
parentd9819b6dcbba3ce86477c4fe045356e452cfd409 (diff)
* DiagnosticsConfigurationHandler.cs: Don't refer to TraceImpl member
while reading the .config file, instead cache the values and refer to the cached values during initialization. This prevents recursive initialization calls (Trace.OnInit() ... Trace.Listeners.Add() ... Trace.OnInit() ...), and associated duplicate parsing of .config file sections. Fixes bnc#499442. * TraceImpl.cs: Cope with DiagnosticsConfigurationHandler changes. * TraceListenerCollection.cs: Add internal Add(TraceListener,TraceImplSettings) method for adding TraceListeners during DiagnosticsConfigurationHandler initialization (which can't access TraceImpl, as we may still be reading the .config file to determine the TraceImpl values). svn path=/trunk/mcs/; revision=133291
Diffstat (limited to 'mcs/class/System/System.Diagnostics/TraceImpl.cs')
-rw-r--r--mcs/class/System/System.Diagnostics/TraceImpl.cs48
1 files changed, 28 insertions, 20 deletions
diff --git a/mcs/class/System/System.Diagnostics/TraceImpl.cs b/mcs/class/System/System.Diagnostics/TraceImpl.cs
index 2b2cc8d5d63..265cd6eb60d 100644
--- a/mcs/class/System/System.Diagnostics/TraceImpl.cs
+++ b/mcs/class/System/System.Diagnostics/TraceImpl.cs
@@ -37,6 +37,19 @@ using System.Threading;
namespace System.Diagnostics {
+ internal class TraceImplSettings {
+ public const string Key = ".__TraceInfoSettingsKey__.";
+
+ public bool AutoFlush;
+ public int IndentLevel, IndentSize = 4;
+ public TraceListenerCollection Listeners = new TraceListenerCollection (false);
+
+ public TraceImplSettings ()
+ {
+ Listeners.Add (new DefaultTraceListener (), this);
+ }
+ }
+
internal class TraceImpl {
private static object initLock = new object ();
@@ -74,14 +87,6 @@ namespace System.Diagnostics {
private static int indentSize;
#endif
- static TraceImpl ()
- {
- // defaults
- autoFlush = false;
- indentLevel = 0;
- indentSize = 4;
- }
-
private TraceImpl ()
{
}
@@ -182,25 +187,28 @@ namespace System.Diagnostics {
//
// There are also some ordering issues.
//
- // The DiagnosticsConfigurationHandler assumes that the TraceImpl.Listeners
- // collection exists (so it can initialize the DefaultTraceListener and
- // add/remove existing listeners).
- private static object InitOnce ()
+ // DiagnosticsConfigurationHandler doesn't store values within TraceImpl,
+ // but instead stores values it reads from the .config file within a
+ // TraceImplSettings object (accessible via the TraceImplSettings.Key key
+ // in the IDictionary returned).
+ private static void InitOnce ()
{
- object d = null;
-
if (initLock != null) {
lock (initLock) {
if (listeners == null) {
- listeners = new TraceListenerCollection (false);
- listeners.Add (new DefaultTraceListener ());
- d = DiagnosticsConfiguration.Settings;
- initLock = null;
+ IDictionary d = DiagnosticsConfiguration.Settings;
+ TraceImplSettings s = (TraceImplSettings) d [TraceImplSettings.Key];
+
+ d.Remove (TraceImplSettings.Key);
+
+ autoFlush = s.AutoFlush;
+ indentLevel = s.IndentLevel;
+ indentSize = s.IndentSize;
+ listeners = s.Listeners;
}
}
+ initLock = null;
}
-
- return d;
}
// FIXME: According to MSDN, this method should display a dialog box