-
Notifications
You must be signed in to change notification settings - Fork 4.6k
/
EventLogPropertySelector.cs
52 lines (44 loc) · 1.6 KB
/
EventLogPropertySelector.cs
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
40
41
42
43
44
45
46
47
48
49
50
51
52
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System.Collections.Generic;
using Microsoft.Win32;
namespace System.Diagnostics.Eventing.Reader
{
/// <summary>
/// Encapsulates the information for fast access to Event Values
/// of an EventLogRecord. An instance of this class is constructed
/// and then passed to EventLogRecord.GetEventPropertyValues.
/// </summary>
public class EventLogPropertySelector : IDisposable
{
public EventLogPropertySelector(IEnumerable<string> propertyQueries)
{
ArgumentNullException.ThrowIfNull(propertyQueries);
string[] paths;
ICollection<string> coll = propertyQueries as ICollection<string>;
if (coll != null)
{
paths = new string[coll.Count];
coll.CopyTo(paths, 0);
}
else
{
List<string> queries;
queries = new List<string>(propertyQueries);
paths = queries.ToArray();
}
Handle = NativeWrapper.EvtCreateRenderContext(paths.Length, paths, UnsafeNativeMethods.EvtRenderContextFlags.EvtRenderContextValues);
}
internal EventLogHandle Handle { get; }
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
protected virtual void Dispose(bool disposing)
{
if (Handle != null && !Handle.IsInvalid)
Handle.Dispose();
}
}
}