Skip to content

Commit 0641d3b

Browse files
committed
Upgraded Communications package
1 parent 117b801 commit 0641d3b

13 files changed

Lines changed: 87 additions & 84 deletions

File tree

ManagedCode.Storage.AspNetExtensions/StorageExtensions.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public static async Task<Result<FileResult>> DownloadAsFileResult(this IStorage
5151
{
5252
var result = await storage.DownloadAsync(blobName, cancellationToken);
5353

54-
if (result.IsError)
54+
if (result.IsFail)
5555
{
5656
return Result<FileResult>.Fail(result.Error!);
5757
}
@@ -70,9 +70,9 @@ public static async Task<Result<FileResult>> DownloadAsFileResult(this IStorage
7070
{
7171
var result = await storage.DownloadAsync(blobMetadata.Name, cancellationToken);
7272

73-
if (result.IsError)
73+
if (result.IsFail)
7474
{
75-
return Result.Fail<FileResult>(result.Error!);
75+
return result.Error!;
7676
}
7777

7878
var fileStream = new FileStreamResult(result.Value!.FileStream, MimeHelper.GetMimeType(result.Value.FileInfo.Extension))

ManagedCode.Storage.Aws/ManagedCode.Storage.Aws.csproj

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,16 @@
1717
</PropertyGroup>
1818

1919
<ItemGroup>
20-
<ProjectReference Include="..\ManagedCode.Storage.Core\ManagedCode.Storage.Core.csproj"/>
20+
<ProjectReference Include="..\ManagedCode.Storage.Core\ManagedCode.Storage.Core.csproj" />
2121
</ItemGroup>
2222

2323
<ItemGroup>
24-
<PackageReference Include="ManagedCode.Communication" Version="0.0.8"/>
25-
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All"/>
26-
<PackageReference Include="AWSSDK.S3" Version="3.7.9.26"/>
27-
<PackageReference Include="Humanizer.Core" Version="2.14.1"/>
28-
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="6.0.1"/>
29-
<PackageReference Include="System.Linq.Async" Version="6.0.1"/>
24+
<PackageReference Include="ManagedCode.Communication" Version="0.1.2" />
25+
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
26+
<PackageReference Include="AWSSDK.S3" Version="3.7.9.26" />
27+
<PackageReference Include="Humanizer.Core" Version="2.14.1" />
28+
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="6.0.1" />
29+
<PackageReference Include="System.Linq.Async" Version="6.0.1" />
3030
</ItemGroup>
3131

3232

ManagedCode.Storage.Azure/AzureStorage.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ protected override async Task<Result<BlobMetadata>> GetBlobMetadataInternalAsync
267267

268268
if (properties is null)
269269
{
270-
return Result<BlobMetadata>.Fail("Properties for file not found");
270+
return new Error<ErrorCode>("Properties for file not found");
271271
}
272272

273273
return Result<BlobMetadata>.Succeed(new BlobMetadata

ManagedCode.Storage.Azure/ManagedCode.Storage.Azure.csproj

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,17 @@
1717
</PropertyGroup>
1818

1919
<ItemGroup>
20-
<ProjectReference Include="..\ManagedCode.Storage.Core\ManagedCode.Storage.Core.csproj"/>
20+
<ProjectReference Include="..\ManagedCode.Storage.Core\ManagedCode.Storage.Core.csproj" />
2121
</ItemGroup>
2222

2323
<ItemGroup>
24-
<PackageReference Include="Azure.Storage.Files.DataLake" Version="12.11.0"/>
25-
<PackageReference Include="ManagedCode.Communication" Version="0.0.8"/>
26-
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All"/>
27-
<PackageReference Include="Azure.Storage.Blobs" Version="12.13.0"/>
28-
<PackageReference Include="Humanizer.Core" Version="2.14.1"/>
29-
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="6.0.1"/>
30-
<PackageReference Include="System.Linq.Async" Version="6.0.1"/>
24+
<PackageReference Include="Azure.Storage.Files.DataLake" Version="12.11.0" />
25+
<PackageReference Include="ManagedCode.Communication" Version="0.1.2" />
26+
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
27+
<PackageReference Include="Azure.Storage.Blobs" Version="12.13.0" />
28+
<PackageReference Include="Humanizer.Core" Version="2.14.1" />
29+
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="6.0.1" />
30+
<PackageReference Include="System.Linq.Async" Version="6.0.1" />
3131
</ItemGroup>
3232

3333

ManagedCode.Storage.AzureDataLake/AzureDataLakeStorage.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
using Azure.Storage.Files.DataLake;
99
using Azure.Storage.Files.DataLake.Models;
1010
using ManagedCode.Communication;
11+
using ManagedCode.Communication.Extensions;
1112
using ManagedCode.Storage.AzureDataLake.Options;
1213
using ManagedCode.Storage.Core;
1314
using ManagedCode.Storage.Core.Models;
@@ -50,7 +51,7 @@ public async Task<Result<Stream>> OpenReadStreamAsync(OpenReadStreamOptions opti
5051
{
5152
var fileClient = GetFileClient(options);
5253
var stream = await fileClient.OpenReadAsync(options.Position, options.BufferSize, cancellationToken: cancellationToken);
53-
return Result.Succeed(stream);
54+
return stream;
5455
}
5556
catch (Exception ex)
5657
{
@@ -66,7 +67,7 @@ public async Task<Result<Stream>> OpenWriteStreamAsync(OpenWriteStreamOptions op
6667
{
6768
var fileClient = GetFileClient(options);
6869
var stream = await fileClient.OpenWriteAsync(options.Overwrite, cancellationToken: cancellationToken);
69-
return Result.Succeed(stream);
70+
return stream;
7071
}
7172
catch (Exception ex)
7273
{
@@ -193,7 +194,7 @@ protected override async Task<Result<bool>> DeleteInternalAsync(DeleteOptions op
193194
{
194195
var fileClient = GetFileClient(options);
195196
await fileClient.DeleteAsync(cancellationToken: cancellationToken);
196-
return Result.Succeed(true);
197+
return true;
197198
}
198199
catch (Exception ex)
199200
{
@@ -208,7 +209,7 @@ protected override async Task<Result<bool>> ExistsInternalAsync(ExistOptions opt
208209
{
209210
var fileClient = GetFileClient(options);
210211
var result = await fileClient.ExistsAsync(cancellationToken);
211-
return Result.Succeed(result.Value);
212+
return result.Value;
212213
}
213214
catch (Exception ex)
214215
{

ManagedCode.Storage.AzureDataLake/ManagedCode.Storage.AzureDataLake.csproj

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,17 @@
1717
</PropertyGroup>
1818

1919
<ItemGroup>
20-
<ProjectReference Include="..\ManagedCode.Storage.Core\ManagedCode.Storage.Core.csproj"/>
20+
<ProjectReference Include="..\ManagedCode.Storage.Core\ManagedCode.Storage.Core.csproj" />
2121
</ItemGroup>
2222

2323
<ItemGroup>
24-
<PackageReference Include="Azure.Storage.Files.DataLake" Version="12.11.0"/>
25-
<PackageReference Include="ManagedCode.Communication" Version="0.0.8"/>
26-
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All"/>
27-
<PackageReference Include="Azure.Storage.Blobs" Version="12.13.0"/>
28-
<PackageReference Include="Humanizer.Core" Version="2.14.1"/>
29-
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="6.0.1"/>
30-
<PackageReference Include="System.Linq.Async" Version="6.0.1"/>
24+
<PackageReference Include="Azure.Storage.Files.DataLake" Version="12.11.0" />
25+
<PackageReference Include="ManagedCode.Communication" Version="0.1.2" />
26+
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
27+
<PackageReference Include="Azure.Storage.Blobs" Version="12.13.0" />
28+
<PackageReference Include="Humanizer.Core" Version="2.14.1" />
29+
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="6.0.1" />
30+
<PackageReference Include="System.Linq.Async" Version="6.0.1" />
3131
</ItemGroup>
3232

3333

ManagedCode.Storage.Core/BaseStorage.cs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using System.Threading;
66
using System.Threading.Tasks;
77
using ManagedCode.Communication;
8+
using ManagedCode.Communication.Extensions;
89
using ManagedCode.MimeTypes;
910
using ManagedCode.Storage.Core.Models;
1011

@@ -134,7 +135,7 @@ public Task<Result<BlobMetadata>> UploadAsync(FileInfo fileInfo, UploadOptions o
134135
public Task<Result<LocalFile>> DownloadAsync(string fileName, CancellationToken cancellationToken = default)
135136
{
136137
var file = new LocalFile();
137-
DownloadOptions options = new() { FileName = fileName };
138+
DownloadOptions options = new() {FileName = fileName};
138139
return DownloadInternalAsync(file, options, cancellationToken);
139140
}
140141

@@ -158,7 +159,7 @@ public Task<Result<LocalFile>> DownloadAsync(Action<DownloadOptions> action, Can
158159

159160
public Task<Result<bool>> DeleteAsync(string fileName, CancellationToken cancellationToken = default)
160161
{
161-
DeleteOptions options = new() { FileName = fileName };
162+
DeleteOptions options = new() {FileName = fileName};
162163
return DeleteInternalAsync(options, cancellationToken);
163164
}
164165

@@ -176,7 +177,7 @@ public Task<Result<bool>> DeleteAsync(Action<DeleteOptions> action, Cancellation
176177

177178
public Task<Result<bool>> ExistsAsync(string fileName, CancellationToken cancellationToken = default)
178179
{
179-
ExistOptions options = new() { FileName = fileName };
180+
ExistOptions options = new() {FileName = fileName};
180181
return ExistsInternalAsync(options, cancellationToken);
181182
}
182183

@@ -194,7 +195,7 @@ public Task<Result<bool>> ExistsAsync(Action<ExistOptions> action, CancellationT
194195

195196
public Task<Result<BlobMetadata>> GetBlobMetadataAsync(string fileName, CancellationToken cancellationToken = default)
196197
{
197-
MetadataOptions options = new() { FileName = fileName };
198+
MetadataOptions options = new() {FileName = fileName};
198199
return GetBlobMetadataInternalAsync(options, cancellationToken);
199200
}
200201

@@ -214,7 +215,7 @@ public Task<Result<BlobMetadata>> GetBlobMetadataAsync(Action<MetadataOptions> a
214215

215216
public Task<Result> SetLegalHoldAsync(bool hasLegalHold, string fileName, CancellationToken cancellationToken = default)
216217
{
217-
LegalHoldOptions options = new() { FileName = fileName };
218+
LegalHoldOptions options = new() {FileName = fileName};
218219
return SetLegalHoldInternalAsync(hasLegalHold, options, cancellationToken);
219220
}
220221

@@ -232,7 +233,7 @@ public Task<Result> SetLegalHoldAsync(bool hasLegalHold, Action<LegalHoldOptions
232233

233234
public Task<Result<bool>> HasLegalHoldAsync(string fileName, CancellationToken cancellationToken = default)
234235
{
235-
LegalHoldOptions options = new() { FileName = fileName };
236+
LegalHoldOptions options = new() {FileName = fileName};
236237
return HasLegalHoldInternalAsync(options, cancellationToken);
237238
}
238239

ManagedCode.Storage.Core/ManagedCode.Storage.Core.csproj

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@
1717
</PropertyGroup>
1818

1919
<ItemGroup>
20-
<PackageReference Include="ManagedCode.Communication" Version="0.0.8"/>
21-
<PackageReference Include="ManagedCode.MimeTypes" Version="1.0.0"/>
22-
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All"/>
23-
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="6.0.0"/>
24-
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="6.0.1"/>
20+
<PackageReference Include="ManagedCode.Communication" Version="0.1.2" />
21+
<PackageReference Include="ManagedCode.MimeTypes" Version="1.0.0" />
22+
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
23+
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="6.0.0" />
24+
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="6.0.1" />
2525
</ItemGroup>
2626

2727
</Project>

ManagedCode.Storage.FileSystem/FileSystemStorage.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using System.Threading;
66
using System.Threading.Tasks;
77
using ManagedCode.Communication;
8+
using ManagedCode.Communication.Extensions;
89
using ManagedCode.MimeTypes;
910
using ManagedCode.Storage.Core;
1011
using ManagedCode.Storage.Core.Models;
@@ -123,8 +124,8 @@ protected override async Task<Result<LocalFile>> DownloadInternalAsync(LocalFile
123124
var filePath = GetPathFromOptions(options);
124125

125126
return File.Exists(filePath)
126-
? Result<LocalFile>.Succeed(new LocalFile(filePath))
127-
: Result<LocalFile>.Fail("File not found");
127+
? new LocalFile(filePath)
128+
: new Error<ErrorCode>("File not found");
128129
}
129130

130131
protected override async Task<Result<bool>> DeleteInternalAsync(DeleteOptions options, CancellationToken cancellationToken = default)
@@ -158,7 +159,7 @@ protected override async Task<Result<BlobMetadata>> GetBlobMetadataInternalAsync
158159

159160
if (!fileInfo.Exists)
160161
{
161-
return Result<BlobMetadata>.Fail("File not found");
162+
return new Error<ErrorCode>("File not found");
162163
}
163164

164165
var result = new BlobMetadata
@@ -185,9 +186,9 @@ protected override async Task<Result> SetLegalHoldInternalAsync(bool hasLegalHol
185186
{
186187
var file = await DownloadAsync(filePath, cancellationToken);
187188

188-
if (file.IsError)
189+
if (file.IsFail)
189190
{
190-
return Result.Fail(file.Error);
191+
return file.Error!;
191192
}
192193

193194
var fileStream = File.OpenRead(file.Value!.FilePath); // Opening with FileAccess.Read only

ManagedCode.Storage.FileSystem/ManagedCode.Storage.FileSystem.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@
1717
</PropertyGroup>
1818

1919
<ItemGroup>
20-
<ProjectReference Include="..\ManagedCode.Storage.Core\ManagedCode.Storage.Core.csproj"/>
20+
<ProjectReference Include="..\ManagedCode.Storage.Core\ManagedCode.Storage.Core.csproj" />
2121
</ItemGroup>
2222

2323
<ItemGroup>
24-
<PackageReference Include="ManagedCode.Communication" Version="0.0.8"/>
25-
<PackageReference Include="ManagedCode.MimeTypes" Version="1.0.0"/>
26-
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All"/>
24+
<PackageReference Include="ManagedCode.Communication" Version="0.1.2" />
25+
<PackageReference Include="ManagedCode.MimeTypes" Version="1.0.0" />
26+
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
2727
</ItemGroup>
2828

2929
</Project>

0 commit comments

Comments
 (0)