TraceUtility.cs source code in C# .NET

Source code for the .NET framework in C#

                        

Code:

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

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

namespace System.IdentityModel.Diagnostics 
{
    using System.Diagnostics; 
    using System.Runtime.CompilerServices; 
    using System.Runtime.Diagnostics;
    using System.Collections.Generic; 

    static class TraceCode
    {
        // IdentityModel TraceCodes 
        public const int IdentityModel = 0xC0000;
        public const int AuthorizationContextCreated = TraceCode.IdentityModel | 0X0002; 
        public const int AuthorizationPolicyEvaluated = TraceCode.IdentityModel | 0X0003; 
    }
 
    static class TraceUtility
    {
        static Dictionary traceCodes = new Dictionary(3)
        { 
            { TraceCode.IdentityModel, "IdentityModel" },
            { TraceCode.AuthorizationContextCreated, "AuthorizationContextCreated" }, 
            { TraceCode.AuthorizationPolicyEvaluated, "AuthorizationPolicyEvaluated" }, 
        };
 
        internal static void TraceEvent(TraceEventType severity, int traceCode, string traceDescription)
        {
            TraceEvent(severity, traceCode, traceDescription, null, null, null);
        } 

        // These methods require a TraceRecord to be allocated, so we want them to show up on profiles if the caller didn't avoid 
        // allocating the TraceRecord by using ShouldTrace. 
        [MethodImpl(MethodImplOptions.NoInlining)]
        internal static void TraceEvent(TraceEventType severity, int traceCode, string traceDescription, TraceRecord extendedData, object source, Exception exception) 
        {
            if (DiagnosticUtility.ShouldTrace(severity))
            {
                Guid activityId = DiagnosticTrace.ActivityId; 
                string msdnTraceCode = System.ServiceModel.Diagnostics.DiagnosticTrace.GenerateMsdnTraceCode("System.IdentityModel", traceCodes[traceCode]);
                DiagnosticUtility.DiagnosticTrace.TraceEvent(severity, traceCode, msdnTraceCode, traceDescription, extendedData, exception, activityId, source); 
            } 
        }
    } 
}

// 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