Seek() public method

public Seek ( int offset ) : void
offset int
return void
Esempio n. 1
0
        public static ICollection <DeltaOperation> Merge(
            IEnumerable <DeltaOperation> lastRevision,
            IEnumerable <DeltaOperation> priorRevision)
        {
            var result = new LinkedList <DeltaOperation>();

            using (var merger = new DeltaSimulator(lastRevision))
            {
                foreach (DeltaOperation operation in priorRevision)
                {
                    switch (operation.Command)
                    {
                    case DeltaCommand.WriteLog:
                        result.AddLast(operation);
                        break;

                    case DeltaCommand.WriteSuccessor:
                        merger.Seek(operation.Offset);
                        merger.Read(operation.Length,
                                    delegate(byte[] data, int offset, int count)
                        {
                            result.AddLast(DeltaOperation.WriteLog(data, offset, count));
                            return(count);
                        },
                                    delegate(int offset, int count)
                        {
                            result.AddLast(DeltaOperation.WriteSuccessor(offset, count));
                            return(count);
                        });
                        break;
                    }
                }
            }
            return(result);
        }
Esempio n. 2
0
 public static ICollection<DeltaOperation> Merge(
     IEnumerable<DeltaOperation> lastRevision,
     IEnumerable<DeltaOperation> priorRevision)
 {
     var result = new LinkedList<DeltaOperation>();
     using (var merger = new DeltaSimulator(lastRevision))
     {
         foreach (DeltaOperation operation in priorRevision)
         {
             switch (operation.Command)
             {
                 case DeltaCommand.WriteLog:
                     result.AddLast(operation);
                     break;
                 case DeltaCommand.WriteSuccessor:
                     merger.Seek(operation.Offset);
                     merger.Read(operation.Length,
                         delegate(byte[] data, int offset, int count)
                         {
                             result.AddLast(DeltaOperation.WriteLog(data, offset, count));
                             return count;
                         },
                         delegate(int offset, int count)
                         {
                             result.AddLast(DeltaOperation.WriteSuccessor(offset, count));
                             return count;
                         });
                     break;
             }
         }
     }
     return result;
 }
Esempio n. 3
0
        public override long Seek(long offset, SeekOrigin origin)
        {
            switch (origin)
            {
            case SeekOrigin.Begin:
                simulator.Seek((int)offset);
                break;

            case SeekOrigin.Current:
                simulator.Seek((int)(Position + offset));
                break;

            case SeekOrigin.End:
                simulator.Seek((int)(Length + offset));
                break;

            default:
                throw new ArgumentException("Invalid origin", "origin");
            }
            return(Position);
        }