ListenerTraceUtility.cs source code in C# .NET

Source code for the .NET framework in C#

                        

Code:

/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / SMSvcHost / System / ServiceModel / Activation / Diagnostics / ListenerTraceUtility.cs / 1 / ListenerTraceUtility.cs

                            //---------------------------------------------------------------------------- 
// Copyright (c) Microsoft Corporation.  All rights reserved.
//---------------------------------------------------------------------------
namespace System.ServiceModel.Activation.Diagnostics
{ 
    using System;
    using System.Diagnostics; 
    using TraceRecord = System.ServiceModel.Diagnostics.TraceRecord; 
    using System.ServiceModel.Diagnostics;
    using System.Globalization; 

    internal static class ListenerTraceUtility
    {
        // NOTE: We need special EventLog in this class so that we can log event even if we can't initialize due to 
        // config errors.
        // 
        const string TraceSourceName = "SMSvcHost 3.0.0.0"; 
        internal static void TraceEvent(TraceEventType severity, TraceCode traceCode, object source)
        { 
            if (DiagnosticUtility.ShouldTrace(severity))
            {
                TraceEvent(severity, traceCode, null, source, (Exception)null);
            } 
        }
 
        internal static void TraceEvent(TraceEventType severity, TraceCode traceCode, object source, Exception exception) 
        {
            TraceEvent(severity, traceCode, null, source, exception); 
        }

        internal static void TraceEvent(TraceEventType severity, TraceCode traceCode, TraceRecord extendedData, object source, Exception exception)
        { 
            if (DiagnosticUtility.ShouldTrace(severity))
            { 
                DiagnosticUtility.DiagnosticTrace.TraceEvent(severity, traceCode, Description(traceCode), extendedData, exception, Guid.Empty, source); 
            }
        } 

        static string Description(TraceCode traceCode)
        {
            // This method's validity is checked via a BVT at 
            // diagnostics\Tracing\TraceCodeVerification
            string descriptionKey = "TraceCode" + DiagnosticTrace.CodeToString(traceCode); 
            return SR.GetString(descriptionKey); 
        }
 
        internal static EventLogger EventLog
        {
            // One doesn't hold onto the EventLogger for a long period of time.
            // Just long enough to log an event. 
#pragma warning disable 618
            get 
            { 
                return new EventLogger(TraceSourceName, null);
            } 
#pragma warning restore 618
        }
    }
} 

// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.


                        

Link Menu

Network programming in C#, Network Programming in VB.NET, Network Programming in .NET
This book is available now!
Buy at Amazon US or
Buy at Amazon UK