Question:You are testing a newly developed method named PersistToDB. This method accepts a parameter of type EventLogEntry. This method does not return a value. You need to create a code segment that helps you to test the method. The code segment must read entries from the application log of local computers and then pass the entries on to the PersistToDB method. The code block must pass only events of type Error or Warning from the source MySource to the PersistToDB method. Which code segment should you use?
A EventLog myLog = new EventLog("Application", ".");
myLog.Source = "MySource";
"A Composite Solution With Just One Click" - Certification Guaranteed 279 Microsoft 70-536 Exam
foreach (EventLogEntry entry in myLog.Entries) {
if (entry.EntryType == EventLogEntryType.Error ||
entry.EntryType == EventLogEntryType.Warning) {
PersistToDB(entry);
}
B EventLog myLog = new EventLog("Application", ".");
foreach (EventLogEntry entry in myLog.Entries) {
if (entry.Source == "MySource") {
if (entry.EntryType == EventLogEntryType.Error ||
entry.EntryType == EventLogEntryType.Warning) {
PersistToDB(entry);
}
}
}
C EventLog myLog = new EventLog("Application", ".");
myLog.Source = "MySource";
foreach (EventLogEntry entry in myLog.Entries) {
if (entry.EntryType == (EventLogEntryType.Error &
EventLogEntryType.Warning)) {
PersistToDB(entry);
}
}
D EventLog myLog = new EventLog("Application", ".");
foreach (EventLogEntry entry in myLog.Entries) {
if (entry.Source == "MySource") {
PersistToDB(entry);
}
}