TraceUtility.cs source code in C# .NET

Source code for the .NET framework in C#

                        

Code:

/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / WCF / Serialization / System / Runtime / Serialization / Diagnostics / TraceUtility.cs / 1305376 / TraceUtility.cs

                            //------------------------------------------------------------------------------ 
// Copyright (c) Microsoft Corporation.  All rights reserved.
//-----------------------------------------------------------------------------

namespace System.Runtime.Serialization.Diagnostics 
{
    using System.Collections.Generic; 
    using System.ServiceModel.Diagnostics; 
    using System.Diagnostics;
    using System.Runtime.Diagnostics; 

    static class TraceUtility
    {
        static Dictionary traceCodes = new Dictionary(18) 
        {
            { TraceCode.WriteObjectBegin, "WriteObjectBegin" }, 
            { TraceCode.WriteObjectEnd, "WriteObjectEnd" }, 
            { TraceCode.WriteObjectContentBegin, "WriteObjectContentBegin" },
            { TraceCode.WriteObjectContentEnd, "WriteObjectContentEnd" }, 
            { TraceCode.ReadObjectBegin, "ReadObjectBegin" },
            { TraceCode.ReadObjectEnd, "ReadObjectEnd" },
            { TraceCode.ElementIgnored, "ElementIgnored" },
            { TraceCode.XsdExportBegin, "XsdExportBegin" }, 
            { TraceCode.XsdExportEnd, "XsdExportEnd" },
            { TraceCode.XsdImportBegin, "XsdImportBegin" }, 
            { TraceCode.XsdImportEnd, "XsdImportEnd" }, 
            { TraceCode.XsdExportError, "XsdExportError" },
            { TraceCode.XsdImportError, "XsdImportError" }, 
            { TraceCode.XsdExportAnnotationFailed, "XsdExportAnnotationFailed" },
            { TraceCode.XsdImportAnnotationFailed, "XsdImportAnnotationFailed" },
            { TraceCode.XsdExportDupItems, "XsdExportDupItems" },
            { TraceCode.FactoryTypeNotFound, "FactoryTypeNotFound" }, 
            { TraceCode.ObjectWithLargeDepth, "ObjectWithLargeDepth" },
        }; 
 
        internal static void Trace(TraceEventType severity, int traceCode, string traceDescription)
        { 
            Trace(severity, traceCode, traceDescription, null);
        }

        internal static void Trace(TraceEventType severity, int traceCode, string traceDescription, TraceRecord record) 
        {
            Trace(severity, traceCode, traceDescription, record, null); 
        } 

        internal static void Trace(TraceEventType severity, int traceCode, string traceDescription, TraceRecord record, Exception exception) 
        {
            string msdnTraceCode = System.ServiceModel.Diagnostics.DiagnosticTrace.GenerateMsdnTraceCode("System.Runtime.Serialization", traceCodes[traceCode]);
            DiagnosticUtility.DiagnosticTrace.TraceEvent(severity, traceCode, msdnTraceCode, traceDescription, record, exception, null);
        } 
    }
} 

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

namespace System.Runtime.Serialization.Diagnostics 
{
    using System.Collections.Generic; 
    using System.ServiceModel.Diagnostics; 
    using System.Diagnostics;
    using System.Runtime.Diagnostics; 

    static class TraceUtility
    {
        static Dictionary traceCodes = new Dictionary(18) 
        {
            { TraceCode.WriteObjectBegin, "WriteObjectBegin" }, 
            { TraceCode.WriteObjectEnd, "WriteObjectEnd" }, 
            { TraceCode.WriteObjectContentBegin, "WriteObjectContentBegin" },
            { TraceCode.WriteObjectContentEnd, "WriteObjectContentEnd" }, 
            { TraceCode.ReadObjectBegin, "ReadObjectBegin" },
            { TraceCode.ReadObjectEnd, "ReadObjectEnd" },
            { TraceCode.ElementIgnored, "ElementIgnored" },
            { TraceCode.XsdExportBegin, "XsdExportBegin" }, 
            { TraceCode.XsdExportEnd, "XsdExportEnd" },
            { TraceCode.XsdImportBegin, "XsdImportBegin" }, 
            { TraceCode.XsdImportEnd, "XsdImportEnd" }, 
            { TraceCode.XsdExportError, "XsdExportError" },
            { TraceCode.XsdImportError, "XsdImportError" }, 
            { TraceCode.XsdExportAnnotationFailed, "XsdExportAnnotationFailed" },
            { TraceCode.XsdImportAnnotationFailed, "XsdImportAnnotationFailed" },
            { TraceCode.XsdExportDupItems, "XsdExportDupItems" },
            { TraceCode.FactoryTypeNotFound, "FactoryTypeNotFound" }, 
            { TraceCode.ObjectWithLargeDepth, "ObjectWithLargeDepth" },
        }; 
 
        internal static void Trace(TraceEventType severity, int traceCode, string traceDescription)
        { 
            Trace(severity, traceCode, traceDescription, null);
        }

        internal static void Trace(TraceEventType severity, int traceCode, string traceDescription, TraceRecord record) 
        {
            Trace(severity, traceCode, traceDescription, record, null); 
        } 

        internal static void Trace(TraceEventType severity, int traceCode, string traceDescription, TraceRecord record, Exception exception) 
        {
            string msdnTraceCode = System.ServiceModel.Diagnostics.DiagnosticTrace.GenerateMsdnTraceCode("System.Runtime.Serialization", traceCodes[traceCode]);
            DiagnosticUtility.DiagnosticTrace.TraceEvent(severity, traceCode, msdnTraceCode, traceDescription, record, exception, null);
        } 
    }
} 

// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
                        

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