blob: cdced968f05727687e6b4b3c3249ec049f53673f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using Interlocked = System.Threading.Interlocked;
#if ES_BUILD_STANDALONE
namespace Microsoft.Diagnostics.Tracing
#else
namespace System.Diagnostics.Tracing
#endif
{
/// <summary>
/// TraceLogging: Contains the metadata needed to emit an event, optimized
/// for events with one top-level compile-time-typed payload object.
/// </summary>
/// <typeparam name="T">
/// Type of the top-level payload object. Should be EmptyStruct if the
/// event has no payload.
/// </typeparam>
internal static class SimpleEventTypes<T>
{
private static TraceLoggingEventTypes instance;
public static TraceLoggingEventTypes Instance
{
get { return instance ?? InitInstance(); }
}
private static TraceLoggingEventTypes InitInstance()
{
var info = TraceLoggingTypeInfo.GetInstance(typeof(T), null);
var newInstance = new TraceLoggingEventTypes(info.Name, info.Tags, new TraceLoggingTypeInfo[] { info });
Interlocked.CompareExchange(ref instance, newInstance, null);
return instance;
}
}
}
|