Represents a single delta operation for a file revision.
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 DeltaOperation WriteLog(byte[] data, int offset, int length)
 {
     var result = new DeltaOperation();
     result.command = DeltaCommand.WriteLog;
     result.length = length;
     result.data = new ArraySegment<byte>(data, offset, length);
     return result;
 }
Esempio n. 3
0
 public static DeltaOperation WriteSuccessor(int offset, int length)
 {
     var result = new DeltaOperation();
     result.command = DeltaCommand.WriteSuccessor;
     result.offset = offset;
     result.length = length;
     return result;
 }
Esempio n. 4
0
        public static DeltaOperation WriteSuccessor(int offset, int length)
        {
            var result = new DeltaOperation();

            result.command = DeltaCommand.WriteSuccessor;
            result.offset  = offset;
            result.length  = length;
            return(result);
        }
Esempio n. 5
0
        public static DeltaOperation WriteLog(byte[] data, int offset, int length)
        {
            var result = new DeltaOperation();

            result.command = DeltaCommand.WriteLog;
            result.length  = length;
            result.data    = new ArraySegment <byte>(data, offset, length);
            return(result);
        }
Esempio n. 6
0
        public override void Read(BufferReader reader, RecordHeader header)
        {
            base.Read(reader, header);

            for (; ; )
            {
                DeltaOperation operation = new DeltaOperation();
                operation.Read(reader);
                if (operation.Command == DeltaCommand.Stop) break;
                operations.AddLast(operation);
            }
        }
Esempio n. 7
0
        public override void Read(BufferReader reader, RecordHeader header)
        {
            base.Read(reader, header);

            for (; ;)
            {
                DeltaOperation operation = new DeltaOperation();
                operation.Read(reader);
                if (operation.Command == DeltaCommand.Stop)
                {
                    break;
                }
                operations.AddLast(operation);
            }
        }