Simulates stream-like traversal over a set of revision delta operations.
Inheritance: IDisposable
Example #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);
        }
Example #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;
 }
Example #3
0
 public DeltaStream(Stream stream, IEnumerable <DeltaOperation> operations)
 {
     baseStream = stream;
     simulator  = new DeltaSimulator(operations);
 }
Example #4
0
 public DeltaStream(Stream stream, IEnumerable<DeltaOperation> operations)
 {
     baseStream = stream;
     simulator = new DeltaSimulator(operations);
 }