Ejemplo n.º 1
0
        protected override async Task ModifyDataAsync(PageBlobClient client, Stream data, ModifyDataMode mode)
        {
            Argument.AssertNotNull(client, nameof(client));
            Argument.AssertNotNull(data, nameof(data));

            long position = mode switch
            {
                ModifyDataMode.Replace => 0,
                ModifyDataMode.Append => (await client.GetPropertiesAsync()).Value.ContentLength,
                _ => throw Errors.InvalidArgument(nameof(mode))
            };

            await client.ResizeAsync(position + data.Length);

            using Stream writeStream = await client.OpenWriteAsync(overwrite : false, position, new PageBlobOpenWriteOptions
            {
                Size = data.Length
            });

            await data.CopyToAsync(writeStream);
        }

        #endregion
    }
        protected override async Task ModifyDataAsync(BlockBlobClient client, Stream data, ModifyDataMode mode)
        {
            Argument.AssertNotNull(client, nameof(client));
            Argument.AssertNotNull(data, nameof(data));

            switch (mode)
            {
            case ModifyDataMode.Replace:
                await UpdateBlobContentsAsync(client, data);

                break;

            case ModifyDataMode.Append:
                await UpdateBlobContentsAsync(
                    client,
                    data,
                    await client.GetBlockListAsync());

                break;

            default:
                throw Errors.InvalidArgument(nameof(mode));
            }
        }
Ejemplo n.º 3
0
 protected abstract Task ModifyDataAsync(
     TResourceClient client,
     Stream data,
     ModifyDataMode mode);
Ejemplo n.º 4
0
 protected override async Task ModifyDataAsync(DataLakeFileClient client, Stream data, ModifyDataMode mode)
 {
     using Stream writeStream = mode switch
           {
               ModifyDataMode.Replace => await client.OpenWriteAsync(overwrite : true),
               ModifyDataMode.Append => await client.OpenWriteAsync(overwrite : false), // method automatically sets position to end
               _ => throw Errors.InvalidArgument(nameof(mode))
           };
     await data.CopyToAsync(writeStream);
 }
Ejemplo n.º 5
0
        protected override async Task ModifyDataAsync(AppendBlobClient client, Stream data, ModifyDataMode mode)
        {
            if (mode == ModifyDataMode.Replace)
            {
                // test framework won't save recordings for inconclusive tests
                // need to pass when recording to have a recording in CI
                if (Recording.Mode == Core.TestFramework.RecordedTestMode.Record)
                {
                    Assert.Pass();
                }
                else
                {
                    Assert.Inconclusive();
                }
            }

            using Stream writeStream = await client.OpenWriteAsync(overwrite : false);

            await data.CopyToAsync(writeStream);
        }