Rediger

Del via


LogRecordSequence.ReadLogRecords Method

Definition

Returns an enumerable collection of records in the sequence. This method cannot be inherited.

public:
 virtual System::Collections::Generic::IEnumerable<System::IO::Log::LogRecord ^> ^ ReadLogRecords(System::IO::Log::SequenceNumber start, System::IO::Log::LogRecordEnumeratorType logRecordEnum);
public System.Collections.Generic.IEnumerable<System.IO.Log.LogRecord> ReadLogRecords (System.IO.Log.SequenceNumber start, System.IO.Log.LogRecordEnumeratorType logRecordEnum);
abstract member ReadLogRecords : System.IO.Log.SequenceNumber * System.IO.Log.LogRecordEnumeratorType -> seq<System.IO.Log.LogRecord>
override this.ReadLogRecords : System.IO.Log.SequenceNumber * System.IO.Log.LogRecordEnumeratorType -> seq<System.IO.Log.LogRecord>
Public Function ReadLogRecords (start As SequenceNumber, logRecordEnum As LogRecordEnumeratorType) As IEnumerable(Of LogRecord)

Parameters

start
SequenceNumber

The sequence number of the first record where the reading starts.

logRecordEnum
LogRecordEnumeratorType

A valid LogRecordEnumeratorType value that specifies the manner (that is, forward or backward) in which records should be read from a LogRecordSequence.

Returns

An enumerable collection of records in the sequence.

Implements

Exceptions

start is not valid for this sequence.

-or-

logRecordEnum is invalid.

-or-

The specified element was not found in the collection.

start is not between the base and last sequence numbers of this sequence.

The request could not be performed because of an unexpected I/O exception.

-or-

The request could not be performed because of an I/O device error.

-or

The buffer size used to write the log record is larger than the buffer size being used to read it.

-or-

The record sequence is corrupted.

-or-

The specified log file format or version is invalid.

-or-

The record was written with an incompatible version of the record sequence.

The operation is invalid because the enumeration has not been started. A call to MoveNext() must be made.

The method was called after the sequence has been disposed of.

There is not enough memory to continue the execution of the program.

Access for the specified log sequence is denied by the operating system.

Examples

This example shows how to use ReadLogRecords in a loop.

foreach (LogRecord record in sequence1.ReadLogRecords(sequence1.BaseSequenceNumber, LogRecordEnumeratorType.Next))
{
    byte[] data = new byte[record.Data.Length];
    record.Data.Read(data, 0, (int)record.Data.Length);
    string mystr = enc.GetString(data);
    Console.WriteLine("    {0}", mystr);
}
For Each record In sequence1.ReadLogRecords(sequence1.BaseSequenceNumber, LogRecordEnumeratorType.Next)
    Dim data(record.Data.Length - 1) As Byte
    record.Data.Read(data, 0, CInt(Fix(record.Data.Length)))
    Dim mystr As String = enc.GetString(data)
    Console.WriteLine("    {0}", mystr)
Next record

Remarks

This method returns an enumerable collection of records in the sequence. The order of the enumerated records depends on the value of the logRecordEnum parameter.

Applies to