IRecordSequence.ReadLogRecords(SequenceNumber, LogRecordEnumeratorType) IRecordSequence.ReadLogRecords(SequenceNumber, LogRecordEnumeratorType) IRecordSequence.ReadLogRecords(SequenceNumber, LogRecordEnumeratorType) IRecordSequence.ReadLogRecords(SequenceNumber, LogRecordEnumeratorType) Method

Definición

Cuando se invalida en una clase derivada, devuelve una colección enumerable de registros en la secuencia.When overridden in a derived class, returns an enumerable collection of records in the sequence.

public:
 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>
Public Function ReadLogRecords (start As SequenceNumber, logRecordEnum As LogRecordEnumeratorType) As IEnumerable(Of LogRecord)

Parámetros

start
SequenceNumber SequenceNumber SequenceNumber SequenceNumber

El número de secuencia del primer registro donde la lectura se inicia.The sequence number of the first record where the reading starts.

logRecordEnum
LogRecordEnumeratorType LogRecordEnumeratorType LogRecordEnumeratorType LogRecordEnumeratorType

Un valor LogRecordEnumeratorType válido que especifica la manera (es decir, hacia adelante o hacia atrás) en la que los registros se deberían leer de LogRecordSequence.A valid LogRecordEnumeratorType value that specifies the manner (that is, forward or backward) in which records should be read from a LogRecordSequence.

Devoluciones

Una colección enumerable de registros en la secuencia.An enumerable collection of records in the sequence.

Excepciones

Uno o varios argumentos no son válidos.One or more of the arguments is invalid.

Ha ocurrido un error de E/S al leer un registro.An I/O error occurred while reading the record.

Se llamó al método una vez eliminada la secuencia.The method was called after the sequence has been disposed of.

Ejemplos

Este ejemplo muestra el uso del método ReadLogRecords .This sample demonstrates the use of the ReadLogRecords method.

using System;  
 using System.IO;  
 using System.IO.Log;  

 class ReadRecordsSample  
 {  
     static SequenceNumber AppendRecord(IRecordSequence sequence,  
                                        string message,  
                                        SequenceNumber user,  
                                        SequenceNumber previous)  
     {  
         MemoryStream data = new MemoryStream();  
         BinaryWriter writer = new BinaryWriter(data);  
         writer.Write(message);  

         ArraySegment<byte>[] segments;  
         segments = new ArraySegment<byte>[1];  
         segments[0] = new ArraySegment(data.GetBuffer(),  
                                        0,  
                                        Data.Length);  

         return sequence.Append(segments,  
                                user,  
                                previous,  
                                WriteFlags.None);  
     }  

     public static void Main(string[] args)  
     {  
         IRecordSequence sequence;  
         sequence = new FileIRecordSequence(args[0]);  

         SequenceNumber a, b, c, d;  

         a = AppendRecord(sequence,  
                          "This is record A",  
                          SequenceNumber.Invalid,  
                          SequenceNumber.Invalid);  
         Console.WriteLine("Record A has sequence number System.IO.Log", a);  

         b = AppendRecord(sequence,  
                          "This is record B",  
                          a,  
                          a);  
         Console.WriteLine("Record B has sequence number System.IO.Log", b);  

         c = AppendRecord(sequence,  
                          "This is record C",  
                          a,  
                          a);  
         Console.WriteLine("Record C has sequence number System.IO.Log", c);  

         d = AppendRecord(sequence,  
                          "This is record D",  
                          b,  
                          c);  
         Console.WriteLine("Record D has sequence number System.IO.Log", d);  

         foreach(LogRecord record in  
                 sequence.ReadLogRecords(a, ReadDirection.Forward))  
         {  
             BinaryReader reader = new BinaryReader(record.Data);  
             Console.WriteLine("System.IO.Log: T:System.IO.Log.IRecordSequence",  
                               record.SequenceNumber,  
                               reader.ReadString());  
         }  

         foreach(LogRecord record in  
                 sequence.ReadLogRecords(d, ReadDirection.User))  
         {  
             BinaryReader reader = new BinaryReader(record.Data);  
             Console.WriteLine("System.IO.Log: T:System.IO.Log.IRecordSequence",  
                               record.SequenceNumber,  
                               reader.ReadString());  
         }  

         foreach(LogRecord record in  
                 sequence.ReadLogRecords(d, ReadDirection.Previous))  
         {  
             BinaryReader reader = new BinaryReader(record.Data);  
             Console.WriteLine("System.IO.Log: T:System.IO.Log.IRecordSequence",  
                               record.SequenceNumber,  
                               reader.ReadString());  
         }  
     }  
       }  

Comentarios

Cuando se invalida en una clase derivada, devuelve una colección enumerable de registros en la secuencia.When overridden in a derived class, returns an enumerable collection of records in the sequence. El orden de los registros enumerados depende del valor del parámetro logRecordEnum.The order of the enumerated records depends on the value of the logRecordEnum parameter.

Se aplica a