Skip to Main Content
C# Cookbook, 2nd Edition
book

C# Cookbook, 2nd Edition

by Jay Hilyard, Stephen Teilhet
January 2006
Intermediate to advanced content levelIntermediate to advanced
1184 pages
43h 23m
English
O'Reilly Media, Inc.
Content preview from C# Cookbook, 2nd Edition
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
Searching Event Log Entries
|
459
Discussion
Other searchable criteria can be added to this class by following the same coding pat-
tern for each search method. For instance, the following example shows how to add
a search method to find all entries that contain a particular username:
public static EventLogEntry[] FindUserName(IEnumerable logEntries,
string userNameQuery)
{
ArrayList entries = new ArrayList( );
foreach (EventLogEntry logEntry in logEntries)
{
if (logEntry.UserName == userNameQuery)
{
entries.Add(logEntry);
}
}
EventLogEntry[] entriesArray = new EventLogEntry[entries.Count];
entries.CopyTo(entriesArray);
return (entriesArray);
}
entries.Add(logEntry);
}
}
EventLogEntry[] entriesArray = new EventLogEntry[entries.Count];
entries.CopyTo(entriesArray);
return (entriesArray);
}
public static EventLogEntry[] FindTimeGeneratedAtOrAfter(
IEnumerable logEntries, DateTime timeGeneratedQuery)
{
ArrayList entries = new ArrayList( );
foreach (EventLogEntry logEntry in logEntries)
{
if (logEntry.TimeGenerated >= timeGeneratedQuery)
{
entries.Add(logEntry);
}
}
EventLogEntry[] entriesArray = new EventLogEntry[entries.Count];
entries.CopyTo(entriesArray);
return (entriesArray);
}
}
Example 8-4. EventSearchLog class (continued)
This is the Title of the Book, eMatter Edition
Copyright ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

C# Cookbook

C# Cookbook

Joe Mayo
C# Cookbook

C# Cookbook

Stephen Teilhet, Jay Hilyard
Head First C#, 4th Edition

Head First C#, 4th Edition

Andrew Stellman, Jennifer Greene

Publisher Resources

ISBN: 0596100639Supplemental ContentCatalog PageErrata