3 // Copyright (c) Microsoft Corporation. All rights reserved.
6 /*============================================================
8 ** Class: EventMetadata
11 ** This public class describes the metadata for a specific event
12 ** raised by Provider. An instance of this class is obtained from
13 ** ProviderMetadata class.
15 ============================================================*/
17 using System.Globalization;
18 using System.Collections.Generic;
19 using System.Runtime.InteropServices;
21 using System.Diagnostics.CodeAnalysis;
23 namespace System.Diagnostics.Eventing.Reader {
27 [System.Security.Permissions.HostProtection(MayLeakOnAbort = true)]
28 public sealed class EventMetadata {
31 private byte channelId;
35 private long keywords;
36 private string template;
37 private string description;
39 ProviderMetadata pmReference;
41 internal EventMetadata(uint id, byte version, byte channelId,
42 byte level, byte opcode, short task, long keywords,
43 string template, string description, ProviderMetadata pmReference) {
45 this.version = version;
46 this.channelId = channelId;
50 this.keywords = keywords;
51 this.template = template;
52 this.description = description;
53 this.pmReference = pmReference;
57 // Max value will be UINT32.MaxValue - it is a long because this property
58 // is really a UINT32. The legacy API allows event message ids to be declared
59 // as UINT32 and these event/messages may be migrated into a Provider's
60 // manifest as UINT32. Note that EventRecord ids are
61 // still declared as int, because those ids max value is UINT16.MaxValue
62 // and rest of the bits of the legacy event id would be stored in
63 // Qualifiers property.
77 public EventLogLink LogLink {
79 return new EventLogLink((uint)this.channelId, this.pmReference);
83 public EventLevel Level {
85 return new EventLevel(this.level, this.pmReference);
89 [SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly", MessageId = "Opcode", Justification = "[....]: Shipped public in 3.5, breaking change to fix now.")]
90 public EventOpcode Opcode {
92 return new EventOpcode(this.opcode, this.pmReference);
96 public EventTask Task {
98 return new EventTask(this.task, this.pmReference);
103 public IEnumerable<EventKeyword> Keywords {
105 List<EventKeyword> list = new List<EventKeyword>();
107 ulong theKeywords = (ulong)this.keywords;
108 ulong mask = 0x8000000000000000;
111 //for (int i = 0; i < 64 && theKeywords != 0; i++)
112 for (int i = 0; i < 64; i++) {
114 if ((theKeywords & mask) > 0) {
115 //the mask is the keyword we will be searching for.
116 list.Add(new EventKeyword((long)mask, this.pmReference));
117 //theKeywords = theKeywords - mask;
119 //modify the mask to check next bit.
127 public string Template {
129 return this.template;
133 public string Description {
135 return this.description;