using System; using System.Threading; using TraceSource = System.Diagnostics.TraceSource; namespace Implab.Diagnostics { /// /// This class is used to provide a single /// instance for the specified class in parameter. /// /// /// The class for which is required. /// /// /// The instance will be created on demand /// and automatically registered in . /// public static class TraceSourceChannel { static Lazy _traceSource = new Lazy(CreateChannel, LazyThreadSafetyMode.ExecutionAndPublication); /// /// The default instance. /// public static TraceSourceChannel Default { get { return _traceSource.Value; } } static TraceSourceChannel CreateChannel() { var channel = new TraceSourceChannel(typeof(T), typeof(T).FullName); TraceRegistry.Global.Register(channel); return channel; } } }