Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions Sources/EventViewerX/EventObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,10 @@ public EventObject(EventRecord eventRecord, string queriedMachine) {

XMLData = eventRecord.ToXml();
// Create a dictionary to hold the xml data
Data = ParseXML(XMLData);
Data = ParseXML<Dictionary<string, string>>(XMLData);
// Create a dictionary to hold the message data
try {
MessageData = ParseMessage(eventRecord.FormatDescription());
MessageData = ParseMessage<Dictionary<string, string>>(eventRecord.FormatDescription());
} catch {
MessageData = new Dictionary<string, string>();
//_logger.WriteError("Error parsing message");
Expand All @@ -169,8 +169,8 @@ public EventObject(EventRecord eventRecord, string queriedMachine) {
/// </summary>
/// <param name="message"></param>
/// <returns></returns>
private Dictionary<string, string> ParseMessage(string message) {
Dictionary<string, string> data = new Dictionary<string, string>();
private T ParseMessage<T>(string message) where T : IDictionary<string, string>, new() {
T data = new();

// Split the message into lines
string[] lines = Regex.Split(message, "\r?\n");
Expand Down Expand Up @@ -242,8 +242,8 @@ private static Dictionary<string, string> ParseColonSeparatedLines(string text)
/// </summary>
/// <param name="xmlData">The XML data.</param>
/// <returns></returns>
private Dictionary<string, string> ParseXML(string xmlData) {
Dictionary<string, string> data = new Dictionary<string, string>();
private T ParseXML<T>(string xmlData) where T : IDictionary<string, string>, new() {
T data = new();

// Parse the XML data into an XElement
XElement root;
Expand Down
Loading