示例#1
0
        protected override ReplicationBatchItem CloneInternal(JsonOperationContext context)
        {
            MemoryStream stream = null;

            if (Stream != null)
            {
                stream = new MemoryStream();
                Stream.CopyTo(stream);

                stream.Position = 0;
                Stream.Position = 0;
            }

            var item = new AttachmentReplicationItem
            {
                ContentType = ContentType.Clone(context),
                Name        = Name.Clone(context),
                Stream      = stream
            };

            var baseMem = Base64Hash.CloneToJsonContext(context, out item.Base64Hash);
            var keyMem  = Key.CloneToJsonContext(context, out item.Key);


            item.ToDispose(new DisposableAction(() =>
            {
                context.ReturnMemory(baseMem);
                context.ReturnMemory(keyMem);
            }));

            return(item);
        }
        protected override ReplicationBatchItem CloneInternal(JsonOperationContext context)
        {
            var item = new AttachmentReplicationItem
            {
                Base64Hash  = Base64Hash,
                ContentType = ContentType,
                Name        = Name,
                Key         = Key,
                Stream      = Stream
            };

            Stream?.SetLength(0);
            return(item);
        }
示例#3
0
        public static unsafe AttachmentReplicationItem From(DocumentsOperationContext context, Attachment attachment)
        {
            var item = new AttachmentReplicationItem
            {
                Type              = ReplicationItemType.Attachment,
                Etag              = attachment.Etag,
                ChangeVector      = attachment.ChangeVector,
                Name              = attachment.Name,
                ContentType       = attachment.ContentType,
                Base64Hash        = attachment.Base64Hash,
                Stream            = attachment.Stream,
                TransactionMarker = attachment.TransactionMarker
            };

            // although the key is LSV but is treated as slice and doesn't respect escaping
            item.ToDispose(Slice.From(context.Allocator, attachment.Key.Buffer, attachment.Key.Size, ByteStringType.Immutable, out item.Key));
            return(item);
        }
示例#4
0
        protected override ReplicationBatchItem CloneInternal(JsonOperationContext context)
        {
            MemoryStream stream = null;

            if (Stream != null)
            {
                stream = new MemoryStream();
                Stream.CopyTo(stream);

                stream.Position = 0;
                Stream.Position = 0;
            }

            var item = new AttachmentReplicationItem
            {
                Base64Hash  = Base64Hash,
                ContentType = ContentType,
                Name        = Name,
                Key         = Key,
                Stream      = stream
            };

            return(item);
        }