mscorlib(4.0.0.0) API with additions
EventLogEntryCollection.cs
1 using System.Collections;
2 
3 namespace System.Diagnostics
4 {
7  {
8  private class EntriesEnumerator : IEnumerator
9  {
10  private EventLogEntryCollection entries;
11 
12  private int num = -1;
13 
14  private EventLogEntry cachedEntry;
15 
16  public object Current
17  {
18  get
19  {
20  if (cachedEntry == null)
21  {
22  throw new InvalidOperationException(SR.GetString("NoCurrentEntry"));
23  }
24  return cachedEntry;
25  }
26  }
27 
28  internal EntriesEnumerator(EventLogEntryCollection entries)
29  {
30  this.entries = entries;
31  }
32 
33  public bool MoveNext()
34  {
35  num++;
36  cachedEntry = entries.GetEntryAtNoThrow(num);
37  return cachedEntry != null;
38  }
39 
40  public void Reset()
41  {
42  num = -1;
43  }
44  }
45 
46  private EventLogInternal log;
47 
50  public int Count => log.EntryCount;
51 
55  public virtual EventLogEntry this[int index]
56  {
57  get
58  {
59  return log.GetEntryAt(index);
60  }
61  }
62 
67  {
68  get
69  {
70  return false;
71  }
72  }
73 
76  object ICollection.SyncRoot
77  {
78  get
79  {
80  return this;
81  }
82  }
83 
84  internal EventLogEntryCollection(EventLogInternal log)
85  {
86  this.log = log;
87  }
88 
92  public void CopyTo(EventLogEntry[] entries, int index)
93  {
94  ((ICollection)this).CopyTo((Array)entries, index);
95  }
96 
100  {
101  return new EntriesEnumerator(this);
102  }
103 
104  internal EventLogEntry GetEntryAtNoThrow(int index)
105  {
106  return log.GetEntryAtNoThrow(index);
107  }
108 
112  void ICollection.CopyTo(Array array, int index)
113  {
114  EventLogEntry[] allEntries = log.GetAllEntries();
115  Array.Copy(allEntries, 0, array, index, allEntries.Length);
116  }
117  }
118 }
object SyncRoot
Gets an object that can be used to synchronize access to the T:System.Collections....
Definition: ICollection.cs:23
void CopyTo(EventLogEntry[] entries, int index)
Copies the elements of the T:System.Diagnostics.EventLogEntryCollection to an array of T:System....
Definition: __Canon.cs:3
Encapsulates a single record in the event log. This class cannot be inherited.
Exposes an enumerator, which supports a simple iteration over a non-generic collection....
Definition: IEnumerable.cs:9
Provides methods for creating, manipulating, searching, and sorting arrays, thereby serving as the ba...
Definition: Array.cs:17
bool IsSynchronized
Gets a value indicating whether access to the T:System.Collections.ICollection is synchronized (threa...
Definition: ICollection.cs:33
Defines size and enumerators for a collection of T:System.Diagnostics.EventLogEntry instances.
int Count
Gets the number of entries in the event log (that is, the number of elements in the T:System....
IEnumerator GetEnumerator()
Supports a simple iteration over the T:System.Diagnostics.EventLogEntryCollection object.
static void Copy(Array sourceArray, Array destinationArray, int length)
Copies a range of elements from an T:System.Array starting at the first element and pastes them into ...
Definition: Array.cs:1275
The exception that is thrown when a method call is invalid for the object's current state.
Defines size, enumerators, and synchronization methods for all nongeneric collections.
Definition: ICollection.cs:8
void CopyTo(Array array, int index)
Copies the elements of the T:System.Collections.ICollection to an T:System.Array, starting at a parti...
Supports a simple iteration over a non-generic collection.
Definition: IEnumerator.cs:9