Skip to content

Commit

Permalink
Updated XML rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
jschick04 authored and bill-long committed Nov 11, 2024
1 parent 8e9e5c5 commit 7cca389
Show file tree
Hide file tree
Showing 20 changed files with 234 additions and 185 deletions.
2 changes: 1 addition & 1 deletion src/EventLogExpert.EventDbTool/DbToolCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// // Licensed under the MIT License.

using EventLogExpert.Eventing.Providers;
using EventLogExpert.Eventing.Reader;
using EventLogExpert.Eventing.Readers;
using System.Text.RegularExpressions;

namespace EventLogExpert.EventDbTool;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using EventLogExpert.Eventing.Helpers;
using EventLogExpert.Eventing.Models;
using EventLogExpert.Eventing.Providers;
using EventLogExpert.Eventing.Reader;
using EventLogExpert.Eventing.Readers;
using System.Diagnostics;
using Xunit.Abstractions;

Expand All @@ -29,8 +29,6 @@ public void ResolveProviderDetails(EventRecord eventRecord, string owningLogName
var details = new EventMessageProvider(eventRecord.ProviderName, tracer).LoadProviderDetails();
providerDetails.TryAdd(eventRecord.ProviderName, details);
}

public string GetXml(EventRecord eventRecord) { throw new NotImplementedException(); }
}

private readonly ITestOutputHelper _outputHelper = outputHelper;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,6 @@ public EventProviderDatabaseEventResolver(IDatabaseCollectionProvider dbCollecti
LoadDatabases(dbCollection.ActiveDatabases);
}

public string GetXml(EventRecord eventRecord)
{
return string.Empty;
}

public void ResolveProviderDetails(EventRecord eventRecord, string owningLogName)
{
providerDetailsLock.EnterUpgradeableReadLock();
Expand Down
15 changes: 13 additions & 2 deletions src/EventLogExpert.Eventing/EventResolvers/EventResolverCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public void ClearAll()
}

/// <summary>Returns the description if it exists in the cache, otherwise adds it to the cache and returns it.</summary>
public string GetDescription(string description)
public string GetOrAddDescription(string description)
{
_descriptionCacheLock.EnterUpgradeableReadLock();

Expand All @@ -43,6 +43,11 @@ public string GetDescription(string description)

try
{
if (_descriptionCache.TryGetValue(description, out result))
{
return result;
}

_descriptionCache.Add(description);

return description;
Expand All @@ -59,7 +64,7 @@ public string GetDescription(string description)
}

/// <summary>Returns the value if it exists in the cache, otherwise adds it to the cache and returns it.</summary>
public string GetValue(string value)
public string GetOrAddValue(string value)
{
_valueCacheLock.EnterUpgradeableReadLock();

Expand All @@ -74,6 +79,12 @@ public string GetValue(string value)

try
{
// Double-check if the value was added by another thread
if (_valueCache.TryGetValue(value, out result))
{
return result;
}

_valueCache.Add(value);

return value;
Expand Down
2 changes: 0 additions & 2 deletions src/EventLogExpert.Eventing/EventResolvers/IEventResolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ public interface IEventResolver
{
public IEnumerable<string> GetKeywordsFromBitmask(EventRecord eventRecord);

public string GetXml(EventRecord eventRecord);

public string ResolveDescription(EventRecord eventRecord);

public void ResolveProviderDetails(EventRecord eventRecord, string owningLogName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public interface IEventResolverCache
{
void ClearAll();

string GetDescription(string description);
string GetOrAddDescription(string description);

string GetValue(string value);
string GetOrAddValue(string value);
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ public sealed class LocalProviderEventResolver(Action<string, LogLevel> tracer)
{
public LocalProviderEventResolver() : this((s, log) => Debug.WriteLine(s)) { }

public string GetXml(EventRecord eventRecord) { return string.Empty; }

public void ResolveProviderDetails(EventRecord eventRecord, string owningLogName)
{
providerDetailsLock.EnterUpgradeableReadLock();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,6 @@ public IEnumerable<string> GetKeywordsFromBitmask(EventRecord eventRecord)
throw new InvalidOperationException("No database or local resolver available.");
}

public string GetXml(EventRecord eventRecord) {
if (_databaseResolver is not null)
{
return _databaseResolver.GetXml(eventRecord);
}

if (_localResolver is not null)
{
return _localResolver.GetXml(eventRecord);
}

throw new InvalidOperationException("No database or local resolver available.");
}

public string ResolveDescription(EventRecord eventRecord)
{
if (_databaseResolver is not null)
Expand Down
Loading

0 comments on commit 7cca389

Please sign in to comment.