Beispiel #1
0
        // Initialize the world.
        //
        // This logically belongs in the static constructor (as it only needs
        // to be done once), except for one thing: if the .config file has a
        // syntax error, .NET throws a ConfigurationException.  If we read the
        // .config file in the static ctor, we throw a ConfigurationException
        // from the static ctor, which results in a TypeLoadException.  Oops.
        // Reading the .config file here will allow the static ctor to
        // complete successfully, allowing us to throw a normal
        // ConfigurationException should the .config file contain an error.
        //
        // There are also some ordering issues.
        //
        // 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()
        {
            if (initLock != null)
            {
                lock (initLock)
                {
                    if (listeners == null)
                    {
#if CONFIGURATION_DEP
                        IDictionary d = DiagnosticsConfiguration.Settings;
#else
                        IDictionary d = new Dictionary <string, object> {
                            { TraceImplSettings.Key, new TraceImplSettings() }
                        };
#endif

                        TraceImplSettings s = (TraceImplSettings)d[TraceImplSettings.Key];

                        d.Remove(TraceImplSettings.Key);

                        autoFlush = s.AutoFlush;
                        //						indentLevel = s.IndentLevel;
                        indentSize = s.IndentSize;
                        listeners  = s.Listeners;
                    }
                }
                initLock = null;
            }
        }
 internal void Add(TraceListener listener, TraceImplSettings settings)
 {
     //			listener.IndentLevel = settings.IndentLevel;
     listener.IndentSize = settings.IndentSize;
     listeners.Add(listener);
 }
		internal void Add (TraceListener listener, TraceImplSettings settings)
			{
			//			listener.IndentLevel = settings.IndentLevel;
			listener.IndentSize = settings.IndentSize;
			listeners.Add (listener);
			}