Skip to content

Commit 9d0da60

Browse files
author
dudchenko610
committed
added provider extensions
1 parent 4f1e803 commit 9d0da60

10 files changed

Lines changed: 202 additions & 7 deletions

File tree

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
using ManagedCode.Storage.Core;
2+
using ManagedCode.Storage.Core.Models;
3+
using System;
4+
using System.Collections.Generic;
5+
using System.IO;
6+
using System.Threading;
7+
using System.Threading.Tasks;
8+
9+
namespace ManagedCode.Storage.Azure
10+
{
11+
public class AzureBlobStorage : IBlobStorage
12+
{
13+
public AzureBlobStorage()
14+
{
15+
16+
}
17+
18+
public Task DeleteAsync(string blob, CancellationToken cancellationToken = default)
19+
{
20+
throw new System.NotImplementedException();
21+
}
22+
23+
public Task DeleteAsync(Blob blob, CancellationToken cancellationToken = default)
24+
{
25+
throw new System.NotImplementedException();
26+
}
27+
28+
public Task DeleteAsync(IEnumerable<string> blobs, CancellationToken cancellationToken = default)
29+
{
30+
throw new System.NotImplementedException();
31+
}
32+
33+
public Task DeleteAsync(IEnumerable<Blob> blobs, CancellationToken cancellationToken = default)
34+
{
35+
throw new System.NotImplementedException();
36+
}
37+
38+
public void Dispose()
39+
{
40+
throw new System.NotImplementedException();
41+
}
42+
43+
public Task<Stream> DownloadAsStreamAsync(string blob, CancellationToken cancellationToken = default)
44+
{
45+
throw new System.NotImplementedException();
46+
}
47+
48+
public Task<Stream> DownloadAsStreamAsync(Blob blob, CancellationToken cancellationToken = default)
49+
{
50+
throw new System.NotImplementedException();
51+
}
52+
53+
public Task<LocalFile> DownloadAsync(string blob, CancellationToken cancellationToken = default)
54+
{
55+
throw new System.NotImplementedException();
56+
}
57+
58+
public Task<LocalFile> DownloadAsync(Blob blob, CancellationToken cancellationToken = default)
59+
{
60+
throw new System.NotImplementedException();
61+
}
62+
63+
public Task<bool> ExistsAsync(string blob, CancellationToken cancellationToken = default)
64+
{
65+
throw new System.NotImplementedException();
66+
}
67+
68+
public Task<bool> ExistsAsync(Blob blob, CancellationToken cancellationToken = default)
69+
{
70+
throw new System.NotImplementedException();
71+
}
72+
73+
public IAsyncEnumerable<bool> ExistsAsync(IEnumerable<string> blobs, CancellationToken cancellationToken = default)
74+
{
75+
throw new System.NotImplementedException();
76+
}
77+
78+
public IAsyncEnumerable<bool> ExistsAsync(IEnumerable<Blob> blobs, CancellationToken cancellationToken = default)
79+
{
80+
throw new System.NotImplementedException();
81+
}
82+
83+
public IAsyncEnumerable<Blob> GetBlob(string blob, CancellationToken cancellationToken = default)
84+
{
85+
throw new System.NotImplementedException();
86+
}
87+
88+
public IAsyncEnumerable<Blob> GetBlob(Blob blob, CancellationToken cancellationToken = default)
89+
{
90+
throw new System.NotImplementedException();
91+
}
92+
93+
public IAsyncEnumerable<Blob> GetBlob(IEnumerable<string> blobs, CancellationToken cancellationToken = default)
94+
{
95+
throw new System.NotImplementedException();
96+
}
97+
98+
public IAsyncEnumerable<Blob> GetBlob(IEnumerable<Blob> blobs, CancellationToken cancellationToken = default)
99+
{
100+
throw new System.NotImplementedException();
101+
}
102+
103+
public IAsyncEnumerable<Blob> GetBlobListAsync(CancellationToken cancellationToken = default)
104+
{
105+
throw new System.NotImplementedException();
106+
}
107+
108+
public Task UploadAsync(string blob, Stream dataStream, bool append = false, CancellationToken cancellationToken = default)
109+
{
110+
throw new System.NotImplementedException();
111+
}
112+
113+
public Task UploadAsync(string blob, string pathToFile, bool append = false, CancellationToken cancellationToken = default)
114+
{
115+
throw new System.NotImplementedException();
116+
}
117+
118+
public Task UploadAsync(Blob blob, Stream dataStream, bool append = false, CancellationToken cancellationToken = default)
119+
{
120+
throw new System.NotImplementedException();
121+
}
122+
123+
public Task UploadAsync(Blob blob, string pathToFile, bool append = false, CancellationToken cancellationToken = default)
124+
{
125+
throw new System.NotImplementedException();
126+
}
127+
}
128+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
namespace ManagedCode.Storage.Azure
2+
{
3+
public class AzureBlobStorageConnectionOptions
4+
{
5+
public string ConnectionString { get; set; }
6+
}
7+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using System;
2+
using Microsoft.Extensions.DependencyInjection;
3+
using Azure.Storage.Blobs;
4+
using ManagedCode.Storage.Core.Builders;
5+
6+
namespace ManagedCode.Storage.Azure.Extensions
7+
{
8+
public static class ProviderExtensions
9+
{
10+
public static ProviderBuilder AddAzureBlobStorage(this ProviderBuilder providerBuilder, Action<AzureBlobStorageConnectionOptions> action)
11+
{
12+
var connectionOptions = new AzureBlobStorageConnectionOptions();
13+
action.Invoke(connectionOptions);
14+
15+
var blobServiceClient = new BlobServiceClient(connectionOptions.ConnectionString);
16+
providerBuilder.ServiceCollection.AddSingleton(blobServiceClient);
17+
18+
return providerBuilder;
19+
}
20+
}
21+
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
</ItemGroup>
2727

2828
<ItemGroup>
29+
<PackageReference Include="Azure.Storage.Blobs" Version="12.10.0" />
2930
<PackageReference Include="Humanizer.Core" Version="2.8.26" />
3031
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="5.0.0" />
3132
<PackageReference Include="System.Linq.Async" Version="5.0.0" />
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using Microsoft.Extensions.DependencyInjection;
2+
3+
namespace ManagedCode.Storage.Core.Builders
4+
{
5+
public class ProviderBuilder
6+
{
7+
public IServiceCollection ServiceCollection { get; }
8+
9+
public ProviderBuilder(IServiceCollection serviceCollection)
10+
{
11+
ServiceCollection = serviceCollection;
12+
}
13+
}
14+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using Microsoft.Extensions.DependencyInjection;
2+
using ManagedCode.Storage.Core.Builders;
3+
4+
namespace ManagedCode.Storage.Core.Extensions
5+
{
6+
public static class ServiceCollectionExtensions
7+
{
8+
public static ProviderBuilder AddManagedCodeStorage(this IServiceCollection serviceCollection)
9+
{
10+
return new ProviderBuilder(serviceCollection);
11+
}
12+
}
13+
}

ManagedCode.Storage.Core/IBlobStorage.cs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33
using System.IO;
44
using System.Threading;
55
using System.Threading.Tasks;
6+
using ManagedCode.Storage.Core.Models;
67

78
namespace ManagedCode.Storage.Core
89
{
9-
public interface IStorage : IDisposable
10+
public interface IBlobStorage : IDisposable
1011
{
1112
IAsyncEnumerable<Blob> GetBlobListAsync(CancellationToken cancellationToken = default);
1213
IAsyncEnumerable<Blob> GetBlob(string blob, CancellationToken cancellationToken = default);
@@ -33,11 +34,5 @@ public interface IStorage : IDisposable
3334
Task<bool> ExistsAsync(Blob blob, CancellationToken cancellationToken = default);
3435
IAsyncEnumerable<bool> ExistsAsync(IEnumerable<string> blobs, CancellationToken cancellationToken = default);
3536
IAsyncEnumerable<bool> ExistsAsync(IEnumerable<Blob> blobs, CancellationToken cancellationToken = default);
36-
37-
}
38-
39-
public class Blob
40-
{
41-
public string Path { get; set; }
4237
}
4338
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
</PropertyGroup>
2323

2424
<ItemGroup>
25+
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="5.0.0" />
2526
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="5.0.0" />
2627
</ItemGroup>
2728

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
namespace ManagedCode.Storage.Core.Models
2+
{
3+
public class Blob
4+
{
5+
public string Path { get; set; }
6+
}
7+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+

2+
namespace ManagedCode.Storage.Tests.Azure
3+
{
4+
public class DependencyInjectionTests
5+
{
6+
7+
}
8+
}

0 commit comments

Comments
 (0)