From 75abc4df05b0c4117b4f2473ce18cd20b63ceba1 Mon Sep 17 00:00:00 2001 From: Adrien Siffermann Date: Thu, 6 May 2021 23:58:13 +0200 Subject: [PATCH 1/2] Proffer.Storage.Azure.Blobs #81 --- Proffer.sln | 28 ++++++------- README.md | 2 +- .../IInMemoryEmailRepository.cs | 2 +- src/Proffer.Email.Smtp/SmtpEmailProvider.cs | 4 +- src/Proffer.Email/Internal/EmailSender.cs | 4 +- src/Proffer.Email/Options/EmailOptions.cs | 2 +- .../ServiceCollectionExtensions.cs | 2 +- .../AzureBlobsStorageProvider.cs} | 14 +++---- ...lobsStorageServiceCollectionExtensions.cs} | 12 +++--- .../AzureBlobsStore.cs} | 40 +++++++++---------- .../Configuration/AzureBlobsParsedOptions.cs} | 20 +++++----- .../AzureBlobsProviderInstanceOptions.cs} | 6 +-- .../AzureBlobsScopedStoreOptions.cs} | 8 ++-- .../Configuration/AzureBlobsStoreOptions.cs} | 6 +-- .../Internal/AzureBlobsFileProperties.cs} | 18 ++++----- .../Internal/AzureBlobsFileReference.cs} | 18 ++++----- .../AzureBlobsListDirectoryWrapper.cs} | 20 +++++----- .../Internal/AzureBlobsListFileWrapper.cs} | 22 +++++----- .../Proffer.Storage.Azure.Blobs.csproj} | 8 ++-- ...ystemStorageServiceCollectionExtensions.cs | 2 +- .../FileSystemStore.cs | 10 ++--- .../Internal/FileSystemFileReference.cs | 2 +- .../Configuration/ConfigurationExtensions.cs | 2 +- src/Proffer.Storage/IStoreExtensions.cs | 4 +- .../Internal/ConfigureProviderOptions.cs | 6 +-- .../Internal/GenericStoreProxy.cs | 6 +-- .../Internal/StorageFactory.cs | 6 +-- .../Internal/StorageProviderBase.cs | 2 +- .../Proffer.Email.SendGrid.Tests.csproj | 2 +- .../Abstract/ConfiguredStoresTestsBase.cs | 2 +- .../AzureBlobsCollection.cs | 7 ++++ .../AzureBlobsFixture.cs} | 28 ++++++------- .../DeleteTests.cs | 8 ++-- .../GenericStoreTests.cs | 12 +++--- .../GetScopedStoreTests.cs | 8 ++-- .../GetSharedAccessSignatureTests.cs | 14 +++---- .../ListTests.cs | 8 ++-- .../Proffer.Storage.Azure.Blobs.Tests.csproj} | 2 +- .../ReadTests.cs | 8 ++-- .../SaveTests.cs | 9 ++--- .../Stores/DefaultContent/Delete/ToDelete.txt | 0 .../DefaultContent/Delete/ToDelete2.txt | 0 .../DefaultContent/Delete/ToSurvive.txt | 0 .../DefaultContent/Delete/ToSurvive2.txt | 0 .../Globbing/template-header.hbs | 0 .../Globbing/template-header.mustache | 0 .../DefaultContent/Globbing/template.hbs | 0 .../DefaultContent/Globbing/template.mustache | 0 .../DefaultContent/Metadata/TextFile.txt | 0 .../DefaultContent/SubDirectory/TextFile2.txt | 0 .../Stores/DefaultContent/TextFile.txt | 0 .../Stores/DefaultContent/Update/TextFile.txt | 0 .../Stores/DefaultContent/template.hbs | 0 .../Stubs/AzureBlobsStoreOptionsStub.cs | 16 ++++++++ .../appsettings.json | 0 .../AzureCollection.cs | 7 ---- .../Stubs/AzureStoreOptionsStub.cs | 16 -------- .../ReadTests.cs | 1 - .../SaveTests.cs | 2 +- ...StorageServiceCollectionExtensionsTests.cs | 2 +- .../StorageFactoryTests.cs | 2 +- .../StubProviderInstanceOptions.cs | 2 +- 62 files changed, 215 insertions(+), 217 deletions(-) rename src/{Proffer.Storage.Azure/AzureStorageProvider.cs => Proffer.Storage.Azure.Blobs/AzureBlobsStorageProvider.cs} (66%) rename src/{Proffer.Storage.Azure/AzureStorageServiceCollectionExtensions.cs => Proffer.Storage.Azure.Blobs/AzureBlobsStorageServiceCollectionExtensions.cs} (59%) rename src/{Proffer.Storage.Azure/AzureStore.cs => Proffer.Storage.Azure.Blobs/AzureBlobsStore.cs} (89%) rename src/{Proffer.Storage.Azure/Configuration/AzureParsedOptions.cs => Proffer.Storage.Azure.Blobs/Configuration/AzureBlobsParsedOptions.cs} (77%) rename src/{Proffer.Storage.Azure/Configuration/AzureProviderInstanceOptions.cs => Proffer.Storage.Azure.Blobs/Configuration/AzureBlobsProviderInstanceOptions.cs} (69%) rename src/{Proffer.Storage.Azure/Configuration/AzureScopedStoreOptions.cs => Proffer.Storage.Azure.Blobs/Configuration/AzureBlobsScopedStoreOptions.cs} (52%) rename src/{Proffer.Storage.Azure/Configuration/AzureStoreOptions.cs => Proffer.Storage.Azure.Blobs/Configuration/AzureBlobsStoreOptions.cs} (91%) rename src/{Proffer.Storage.Azure/Internal/AzureFileProperties.cs => Proffer.Storage.Azure.Blobs/Internal/AzureBlobsFileProperties.cs} (89%) rename src/{Proffer.Storage.Azure/Internal/AzureFileReference.cs => Proffer.Storage.Azure.Blobs/Internal/AzureBlobsFileReference.cs} (89%) rename src/{Proffer.Storage.Azure/Internal/AzureListDirectoryWrapper.cs => Proffer.Storage.Azure.Blobs/Internal/AzureBlobsListDirectoryWrapper.cs} (79%) rename src/{Proffer.Storage.Azure/Internal/AzureListFileWrapper.cs => Proffer.Storage.Azure.Blobs/Internal/AzureBlobsListFileWrapper.cs} (53%) rename src/{Proffer.Storage.Azure/Proffer.Storage.Azure.csproj => Proffer.Storage.Azure.Blobs/Proffer.Storage.Azure.Blobs.csproj} (75%) rename tests/{Proffer.Storage.Azure.Tests => Proffer.Storage.Azure.Blobs.Tests}/Abstract/ConfiguredStoresTestsBase.cs (93%) create mode 100644 tests/Proffer.Storage.Azure.Blobs.Tests/AzureBlobsCollection.cs rename tests/{Proffer.Storage.Azure.Tests/AzureFixture.cs => Proffer.Storage.Azure.Blobs.Tests/AzureBlobsFixture.cs} (83%) rename tests/{Proffer.Storage.Azure.Tests => Proffer.Storage.Azure.Blobs.Tests}/DeleteTests.cs (87%) rename tests/{Proffer.Storage.Azure.Tests => Proffer.Storage.Azure.Blobs.Tests}/GenericStoreTests.cs (70%) rename tests/{Proffer.Storage.Azure.Tests => Proffer.Storage.Azure.Blobs.Tests}/GetScopedStoreTests.cs (83%) rename tests/{Proffer.Storage.Azure.Tests => Proffer.Storage.Azure.Blobs.Tests}/GetSharedAccessSignatureTests.cs (81%) rename tests/{Proffer.Storage.Azure.Tests => Proffer.Storage.Azure.Blobs.Tests}/ListTests.cs (96%) rename tests/{Proffer.Storage.Azure.Tests/Proffer.Storage.Azure.Tests.csproj => Proffer.Storage.Azure.Blobs.Tests/Proffer.Storage.Azure.Blobs.Tests.csproj} (93%) rename tests/{Proffer.Storage.Azure.Tests => Proffer.Storage.Azure.Blobs.Tests}/ReadTests.cs (97%) rename tests/{Proffer.Storage.Azure.Tests => Proffer.Storage.Azure.Blobs.Tests}/SaveTests.cs (97%) rename tests/{Proffer.Storage.Azure.Tests => Proffer.Storage.Azure.Blobs.Tests}/Stores/DefaultContent/Delete/ToDelete.txt (100%) rename tests/{Proffer.Storage.Azure.Tests => Proffer.Storage.Azure.Blobs.Tests}/Stores/DefaultContent/Delete/ToDelete2.txt (100%) rename tests/{Proffer.Storage.Azure.Tests => Proffer.Storage.Azure.Blobs.Tests}/Stores/DefaultContent/Delete/ToSurvive.txt (100%) rename tests/{Proffer.Storage.Azure.Tests => Proffer.Storage.Azure.Blobs.Tests}/Stores/DefaultContent/Delete/ToSurvive2.txt (100%) rename tests/{Proffer.Storage.Azure.Tests => Proffer.Storage.Azure.Blobs.Tests}/Stores/DefaultContent/Globbing/template-header.hbs (100%) rename tests/{Proffer.Storage.Azure.Tests => Proffer.Storage.Azure.Blobs.Tests}/Stores/DefaultContent/Globbing/template-header.mustache (100%) rename tests/{Proffer.Storage.Azure.Tests => Proffer.Storage.Azure.Blobs.Tests}/Stores/DefaultContent/Globbing/template.hbs (100%) rename tests/{Proffer.Storage.Azure.Tests => Proffer.Storage.Azure.Blobs.Tests}/Stores/DefaultContent/Globbing/template.mustache (100%) rename tests/{Proffer.Storage.Azure.Tests => Proffer.Storage.Azure.Blobs.Tests}/Stores/DefaultContent/Metadata/TextFile.txt (100%) rename tests/{Proffer.Storage.Azure.Tests => Proffer.Storage.Azure.Blobs.Tests}/Stores/DefaultContent/SubDirectory/TextFile2.txt (100%) rename tests/{Proffer.Storage.Azure.Tests => Proffer.Storage.Azure.Blobs.Tests}/Stores/DefaultContent/TextFile.txt (100%) rename tests/{Proffer.Storage.Azure.Tests => Proffer.Storage.Azure.Blobs.Tests}/Stores/DefaultContent/Update/TextFile.txt (100%) rename tests/{Proffer.Storage.Azure.Tests => Proffer.Storage.Azure.Blobs.Tests}/Stores/DefaultContent/template.hbs (100%) create mode 100644 tests/Proffer.Storage.Azure.Blobs.Tests/Stubs/AzureBlobsStoreOptionsStub.cs rename tests/{Proffer.Storage.Azure.Tests => Proffer.Storage.Azure.Blobs.Tests}/appsettings.json (100%) delete mode 100644 tests/Proffer.Storage.Azure.Tests/AzureCollection.cs delete mode 100644 tests/Proffer.Storage.Azure.Tests/Stubs/AzureStoreOptionsStub.cs diff --git a/Proffer.sln b/Proffer.sln index e978322..f514f7d 100644 --- a/Proffer.sln +++ b/Proffer.sln @@ -31,8 +31,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Proffer.Storage", "src\Proffer.Storage\Proffer.Storage.csproj", "{0CA36021-3FA3-4688-8D61-A2B8A0FB168C}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Proffer.Storage.Azure", "src\Proffer.Storage.Azure\Proffer.Storage.Azure.csproj", "{D2422F9C-B64F-47B9-AFFF-EC7899AA956D}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Proffer.Storage.FileSystem", "src\Proffer.Storage.FileSystem\Proffer.Storage.FileSystem.csproj", "{F53D7921-7828-4AF6-BE1E-DB81E80A65CC}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Proffer.Storage.FileSystem.Properties.Json", "src\Proffer.Storage.FileSystem.Properties.Json\Proffer.Storage.FileSystem.Properties.Json.csproj", "{E72BC0D9-6BD2-4D8D-8A59-ABB2815B1E85}" @@ -57,8 +55,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{EB0DAEC2 EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Proffer.Testing", "tests\Proffer.Testing\Proffer.Testing.csproj", "{815899B8-C129-469A-B169-2A59E65181F1}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Proffer.Storage.Azure.Tests", "tests\Proffer.Storage.Azure.Tests\Proffer.Storage.Azure.Tests.csproj", "{E41AF4E2-9692-4BF2-BDBB-3F36A2135ADB}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Proffer.Email.SendGrid.Tests", "tests\Proffer.Email.SendGrid.Tests\Proffer.Email.SendGrid.Tests.csproj", "{A1BABC33-523C-419B-8407-67A3BCE53737}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Proffer.Storage.Tests", "tests\Proffer.Storage.Tests\Proffer.Storage.Tests.csproj", "{1BBECE5A-7008-4D23-9DC6-FEC42AB57D85}" @@ -69,6 +65,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Proffer.Storage.FileSystem. EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Proffer.Storage.FileSystem.Server.Tests", "tests\Proffer.Storage.FileSystem.Server.Tests\Proffer.Storage.FileSystem.Server.Tests.csproj", "{FDA33857-554F-4616-A674-06417AD6A0AF}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Proffer.Storage.Azure.Blobs", "src\Proffer.Storage.Azure.Blobs\Proffer.Storage.Azure.Blobs.csproj", "{E0015649-ADB8-4D25-A14E-B2D5D3AD633F}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Proffer.Storage.Azure.Blobs.Tests", "tests\Proffer.Storage.Azure.Blobs.Tests\Proffer.Storage.Azure.Blobs.Tests.csproj", "{FE0568DD-0D79-4A87-B67D-751E8880F909}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -79,10 +79,6 @@ Global {0CA36021-3FA3-4688-8D61-A2B8A0FB168C}.Debug|Any CPU.Build.0 = Debug|Any CPU {0CA36021-3FA3-4688-8D61-A2B8A0FB168C}.Release|Any CPU.ActiveCfg = Release|Any CPU {0CA36021-3FA3-4688-8D61-A2B8A0FB168C}.Release|Any CPU.Build.0 = Release|Any CPU - {D2422F9C-B64F-47B9-AFFF-EC7899AA956D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {D2422F9C-B64F-47B9-AFFF-EC7899AA956D}.Debug|Any CPU.Build.0 = Debug|Any CPU - {D2422F9C-B64F-47B9-AFFF-EC7899AA956D}.Release|Any CPU.ActiveCfg = Release|Any CPU - {D2422F9C-B64F-47B9-AFFF-EC7899AA956D}.Release|Any CPU.Build.0 = Release|Any CPU {F53D7921-7828-4AF6-BE1E-DB81E80A65CC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {F53D7921-7828-4AF6-BE1E-DB81E80A65CC}.Debug|Any CPU.Build.0 = Debug|Any CPU {F53D7921-7828-4AF6-BE1E-DB81E80A65CC}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -127,10 +123,6 @@ Global {815899B8-C129-469A-B169-2A59E65181F1}.Debug|Any CPU.Build.0 = Debug|Any CPU {815899B8-C129-469A-B169-2A59E65181F1}.Release|Any CPU.ActiveCfg = Release|Any CPU {815899B8-C129-469A-B169-2A59E65181F1}.Release|Any CPU.Build.0 = Release|Any CPU - {E41AF4E2-9692-4BF2-BDBB-3F36A2135ADB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {E41AF4E2-9692-4BF2-BDBB-3F36A2135ADB}.Debug|Any CPU.Build.0 = Debug|Any CPU - {E41AF4E2-9692-4BF2-BDBB-3F36A2135ADB}.Release|Any CPU.ActiveCfg = Release|Any CPU - {E41AF4E2-9692-4BF2-BDBB-3F36A2135ADB}.Release|Any CPU.Build.0 = Release|Any CPU {A1BABC33-523C-419B-8407-67A3BCE53737}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {A1BABC33-523C-419B-8407-67A3BCE53737}.Debug|Any CPU.Build.0 = Debug|Any CPU {A1BABC33-523C-419B-8407-67A3BCE53737}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -151,6 +143,14 @@ Global {FDA33857-554F-4616-A674-06417AD6A0AF}.Debug|Any CPU.Build.0 = Debug|Any CPU {FDA33857-554F-4616-A674-06417AD6A0AF}.Release|Any CPU.ActiveCfg = Release|Any CPU {FDA33857-554F-4616-A674-06417AD6A0AF}.Release|Any CPU.Build.0 = Release|Any CPU + {E0015649-ADB8-4D25-A14E-B2D5D3AD633F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E0015649-ADB8-4D25-A14E-B2D5D3AD633F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E0015649-ADB8-4D25-A14E-B2D5D3AD633F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E0015649-ADB8-4D25-A14E-B2D5D3AD633F}.Release|Any CPU.Build.0 = Release|Any CPU + {FE0568DD-0D79-4A87-B67D-751E8880F909}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FE0568DD-0D79-4A87-B67D-751E8880F909}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FE0568DD-0D79-4A87-B67D-751E8880F909}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FE0568DD-0D79-4A87-B67D-751E8880F909}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -158,7 +158,6 @@ Global GlobalSection(NestedProjects) = preSolution {4E4394F6-91C7-43E2-BEDA-B7F8EBBA2C68} = {A08DBB7E-DDD4-49BB-9A49-5E3FB88EE878} {0CA36021-3FA3-4688-8D61-A2B8A0FB168C} = {8B67DB72-5CC8-441F-9EFF-8F41BB637DA8} - {D2422F9C-B64F-47B9-AFFF-EC7899AA956D} = {8B67DB72-5CC8-441F-9EFF-8F41BB637DA8} {F53D7921-7828-4AF6-BE1E-DB81E80A65CC} = {8B67DB72-5CC8-441F-9EFF-8F41BB637DA8} {E72BC0D9-6BD2-4D8D-8A59-ABB2815B1E85} = {8B67DB72-5CC8-441F-9EFF-8F41BB637DA8} {BB8C05EF-BC14-4C92-9B07-2A616BA0FF45} = {8B67DB72-5CC8-441F-9EFF-8F41BB637DA8} @@ -170,12 +169,13 @@ Global {71EB6650-2C03-4DA2-89FA-C4443CB0FB2A} = {8B67DB72-5CC8-441F-9EFF-8F41BB637DA8} {60BA8317-9CDB-4002-9E43-88EB8BBB3280} = {8B67DB72-5CC8-441F-9EFF-8F41BB637DA8} {815899B8-C129-469A-B169-2A59E65181F1} = {EB0DAEC2-2EEE-4833-8180-353882615CEC} - {E41AF4E2-9692-4BF2-BDBB-3F36A2135ADB} = {EB0DAEC2-2EEE-4833-8180-353882615CEC} {A1BABC33-523C-419B-8407-67A3BCE53737} = {EB0DAEC2-2EEE-4833-8180-353882615CEC} {1BBECE5A-7008-4D23-9DC6-FEC42AB57D85} = {EB0DAEC2-2EEE-4833-8180-353882615CEC} {62473356-141D-438C-8D51-D34191F08A26} = {EB0DAEC2-2EEE-4833-8180-353882615CEC} {1C21F39F-1045-4890-820E-F4328A2BAF86} = {EB0DAEC2-2EEE-4833-8180-353882615CEC} {FDA33857-554F-4616-A674-06417AD6A0AF} = {EB0DAEC2-2EEE-4833-8180-353882615CEC} + {E0015649-ADB8-4D25-A14E-B2D5D3AD633F} = {8B67DB72-5CC8-441F-9EFF-8F41BB637DA8} + {FE0568DD-0D79-4A87-B67D-751E8880F909} = {EB0DAEC2-2EEE-4833-8180-353882615CEC} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {6E14A063-006D-442F-BBA4-C9CF12D2438A} diff --git a/README.md b/README.md index aba1486..2a83278 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ | Package | Current version | Downloads | |---|---|---| | Proffer.Storage | [![NuGet](https://img.shields.io/nuget/v/Proffer.Storage.svg)](https://www.nuget.org/packages/Proffer.Storage/) | [![NuGet](https://img.shields.io/nuget/dt/Proffer.Storage.svg)](https://www.nuget.org/packages/Proffer.Storage/) -| Proffer.Storage.Azure | [![NuGet](https://img.shields.io/nuget/v/Proffer.Storage.Azure.svg)](https://www.nuget.org/packages/Proffer.Storage.Azure/) | [![NuGet](https://img.shields.io/nuget/dt/Proffer.Storage.Azure.svg)](https://www.nuget.org/packages/Proffer.Storage.Azure/) +| Proffer.Storage.Azure.Blobs | [![NuGet](https://img.shields.io/nuget/v/Proffer.Storage.Azure.Blobs.svg)](https://www.nuget.org/packages/Proffer.Storage.Azure.Blobs/) | [![NuGet](https://img.shields.io/nuget/dt/Proffer.Storage.Azure.Blobs.svg)](https://www.nuget.org/packages/Proffer.Storage.Azure.Blobs/) | Proffer.Storage.FileSystem.Properties.Json | [![NuGet](https://img.shields.io/nuget/v/Proffer.Storage.FileSystem.Properties.Json.svg)](https://www.nuget.org/packages/Proffer.Storage.FileSystem.Properties.Json/) | [![NuGet](https://img.shields.io/nuget/dt/Proffer.Storage.FileSystem.Properties.Json.svg)](https://www.nuget.org/packages/Proffer.Storage.FileSystem.Properties.Json/) | Proffer.Storage.FileSystem.Server | [![NuGet](https://img.shields.io/nuget/v/Proffer.Storage.FileSystem.Server.svg)](https://www.nuget.org/packages/Proffer.Storage.FileSystem.Server/) | [![NuGet](https://img.shields.io/nuget/dt/Proffer.Storage.FileSystem.Server.svg)](https://www.nuget.org/packages/Proffer.Storage.FileSystem.Server/) | Proffer.Templating | [![NuGet](https://img.shields.io/nuget/v/Proffer.Templating.svg)](https://www.nuget.org/packages/Proffer.Templating/) | [![NuGet](https://img.shields.io/nuget/dt/Proffer.Templating.svg)](https://www.nuget.org/packages/Proffer.Templating/) diff --git a/src/Proffer.Email.InMemory/IInMemoryEmailRepository.cs b/src/Proffer.Email.InMemory/IInMemoryEmailRepository.cs index 615ced7..7eeac34 100644 --- a/src/Proffer.Email.InMemory/IInMemoryEmailRepository.cs +++ b/src/Proffer.Email.InMemory/IInMemoryEmailRepository.cs @@ -10,7 +10,7 @@ public interface IInMemoryEmailRepository /// /// Gets the emails store. /// - IReadOnlyCollection Store { get;} + IReadOnlyCollection Store { get; } /// /// Saves the specified email in the store. diff --git a/src/Proffer.Email.Smtp/SmtpEmailProvider.cs b/src/Proffer.Email.Smtp/SmtpEmailProvider.cs index 9de8971..8bc68aa 100644 --- a/src/Proffer.Email.Smtp/SmtpEmailProvider.cs +++ b/src/Proffer.Email.Smtp/SmtpEmailProvider.cs @@ -89,11 +89,11 @@ public async Task SendEmailAsync(IEmailAddress from, IEnumerable var message = new MimeMessage(); message.From.Add(new MailboxAddress(from.DisplayName, from.Email)); - if(replyTo != null) + if (replyTo != null) { message.ReplyTo.Add(new MailboxAddress(replyTo.DisplayName, replyTo.Email)); } - + foreach (IEmailAddress recipient in recipients) { message.To.Add(new MailboxAddress(recipient.DisplayName, recipient.Email)); diff --git a/src/Proffer.Email/Internal/EmailSender.cs b/src/Proffer.Email/Internal/EmailSender.cs index 77d8cc6..90a36b1 100644 --- a/src/Proffer.Email/Internal/EmailSender.cs +++ b/src/Proffer.Email/Internal/EmailSender.cs @@ -1,11 +1,11 @@ namespace Proffer.Email.Internal { - using Microsoft.Extensions.Options; - using Storage; using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; + using Microsoft.Extensions.Options; + using Storage; using Templating; /// diff --git a/src/Proffer.Email/Options/EmailOptions.cs b/src/Proffer.Email/Options/EmailOptions.cs index 33a8ea6..4ea99e6 100644 --- a/src/Proffer.Email/Options/EmailOptions.cs +++ b/src/Proffer.Email/Options/EmailOptions.cs @@ -5,7 +5,7 @@ namespace Proffer.Email /// /// The Proffer.Email options with providers. /// - public class EmailOptions + public class EmailOptions { /// /// The default configuration section name. diff --git a/src/Proffer.Email/ServiceCollectionExtensions.cs b/src/Proffer.Email/ServiceCollectionExtensions.cs index 9b5f5bd..bad7dd8 100644 --- a/src/Proffer.Email/ServiceCollectionExtensions.cs +++ b/src/Proffer.Email/ServiceCollectionExtensions.cs @@ -45,7 +45,7 @@ public static IServiceCollection AddEmail(this IServiceCollection services, ICon public static IServiceCollection AddEmail(this IServiceCollection services, IConfigurationRoot configurationRoot, string sectionName = EmailOptions.DefaultConfigurationSectionName) { return services - .Configure(configurationRoot.GetSection(sectionName)) + .Configure(configurationRoot.GetSection(sectionName)) .AddEmail(); } } diff --git a/src/Proffer.Storage.Azure/AzureStorageProvider.cs b/src/Proffer.Storage.Azure.Blobs/AzureBlobsStorageProvider.cs similarity index 66% rename from src/Proffer.Storage.Azure/AzureStorageProvider.cs rename to src/Proffer.Storage.Azure.Blobs/AzureBlobsStorageProvider.cs index 1197e31..7e5c3da 100644 --- a/src/Proffer.Storage.Azure/AzureStorageProvider.cs +++ b/src/Proffer.Storage.Azure.Blobs/AzureBlobsStorageProvider.cs @@ -1,7 +1,7 @@ -namespace Proffer.Storage.Azure +namespace Proffer.Storage.Azure.Blobs { using Microsoft.Extensions.Options; - using Proffer.Storage.Azure.Configuration; + using Proffer.Storage.Azure.Blobs.Configuration; using Proffer.Storage.Internal; using Storage; @@ -9,18 +9,18 @@ namespace Proffer.Storage.Azure /// A provider to handle and build file stores pointing on an Azure Storage account. /// /// - public class AzureStorageProvider : StorageProviderBase + public class AzureBlobsStorageProvider : StorageProviderBase { /// - /// The name. + /// The name. /// public const string ProviderName = "Azure"; /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The options. - public AzureStorageProvider(IOptions options) + public AzureBlobsStorageProvider(IOptions options) : base(options) { } @@ -38,6 +38,6 @@ public AzureStorageProvider(IOptions options) /// /// A configured . /// - protected override IStore BuildStoreInternal(string storeName, AzureStoreOptions storeOptions) => new AzureStore(storeOptions); + protected override IStore BuildStoreInternal(string storeName, AzureBlobsStoreOptions storeOptions) => new AzureBlobsStore(storeOptions); } } diff --git a/src/Proffer.Storage.Azure/AzureStorageServiceCollectionExtensions.cs b/src/Proffer.Storage.Azure.Blobs/AzureBlobsStorageServiceCollectionExtensions.cs similarity index 59% rename from src/Proffer.Storage.Azure/AzureStorageServiceCollectionExtensions.cs rename to src/Proffer.Storage.Azure.Blobs/AzureBlobsStorageServiceCollectionExtensions.cs index 53bbe9d..2d21881 100644 --- a/src/Proffer.Storage.Azure/AzureStorageServiceCollectionExtensions.cs +++ b/src/Proffer.Storage.Azure.Blobs/AzureBlobsStorageServiceCollectionExtensions.cs @@ -1,27 +1,27 @@ namespace Proffer.Storage { - using Azure; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.Extensions.Options; - using Proffer.Storage.Azure.Configuration; + using Proffer.Storage.Azure.Blobs; + using Proffer.Storage.Azure.Blobs.Configuration; using Proffer.Storage.Internal; /// /// extension methods. /// - public static class AzureStorageServiceCollectionExtensions + public static class AzureBlobsStorageServiceCollectionExtensions { /// - /// Registers the Proffer.Storage services to Azure Storage. + /// Registers the Proffer.Storage services to Azure Blobs. /// /// The service collection. /// The service collection. public static IServiceCollection AddAzureStorage(this IServiceCollection services) { services - .AddSingleton, ConfigureProviderOptions>() - .TryAddEnumerable(ServiceDescriptor.Transient()); + .AddSingleton, ConfigureProviderOptions>() + .TryAddEnumerable(ServiceDescriptor.Transient()); return services; } diff --git a/src/Proffer.Storage.Azure/AzureStore.cs b/src/Proffer.Storage.Azure.Blobs/AzureBlobsStore.cs similarity index 89% rename from src/Proffer.Storage.Azure/AzureStore.cs rename to src/Proffer.Storage.Azure.Blobs/AzureBlobsStore.cs index 83070f0..3ac25e5 100644 --- a/src/Proffer.Storage.Azure/AzureStore.cs +++ b/src/Proffer.Storage.Azure.Blobs/AzureBlobsStore.cs @@ -1,4 +1,4 @@ -namespace Proffer.Storage.Azure +namespace Proffer.Storage.Azure.Blobs { using System; using System.Collections.Generic; @@ -12,22 +12,22 @@ namespace Proffer.Storage.Azure using global::Azure.Storage.Blobs; using global::Azure.Storage.Blobs.Models; using global::Azure.Storage.Sas; - using Proffer.Storage.Azure.Configuration; + using Proffer.Storage.Azure.Blobs.Configuration; /// - /// An Azure store allows to save, list or read files on a container in its configured . + /// An Azure store allows to save, list or read files on a container in its configured . /// /// - public class AzureStore : IStore + public class AzureBlobsStore : IStore { - private readonly AzureStoreOptions storeOptions; + private readonly AzureBlobsStoreOptions storeOptions; private readonly BlobContainerClient container; /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The store options. - public AzureStore(AzureStoreOptions storeOptions) + public AzureBlobsStore(AzureBlobsStoreOptions storeOptions) { storeOptions.Validate(); @@ -75,7 +75,7 @@ public async ValueTask ListAsync(string path, bool recursive, .Select(blobItem => { BlobClient blobClient = this.container.GetBlobClient(blobItem.Name); - return new Internal.AzureFileReference(blobClient, new Internal.AzureFileProperties(blobClient, blobItem)); + return new Internal.AzureBlobsFileReference(blobClient, new Internal.AzureBlobsFileProperties(blobClient, blobItem)); }) .ToArray(); } @@ -111,11 +111,11 @@ public async ValueTask ListAsync(string path, string searchPat .Select(blobItem => { BlobClient blobClient = this.container.GetBlobClient(blobItem.Name); - return new Internal.AzureFileReference(blobClient, new Internal.AzureFileProperties(blobClient, blobItem)); + return new Internal.AzureBlobsFileReference(blobClient, new Internal.AzureBlobsFileProperties(blobClient, blobItem)); }) .ToDictionary(x => Path.GetFileName(x.Path)); - Microsoft.Extensions.FileSystemGlobbing.PatternMatchingResult filteredResults = matcher.Execute(new Internal.AzureListDirectoryWrapper(path, pathMap)); + Microsoft.Extensions.FileSystemGlobbing.PatternMatchingResult filteredResults = matcher.Execute(new Internal.AzureBlobsListDirectoryWrapper(path, pathMap)); return filteredResults.Files.Select(x => pathMap[x.Path]).ToArray(); } @@ -149,7 +149,7 @@ public async ValueTask GetAsync(Uri uri, bool withMetadata) /// The reference holding the file path. public async Task DeleteAsync(IPrivateFileReference file) { - Internal.AzureFileReference fileReference = await this.InternalGetAsync(file); + Internal.AzureBlobsFileReference fileReference = await this.InternalGetAsync(file); await fileReference.DeleteAsync(); } @@ -162,7 +162,7 @@ public async Task DeleteAsync(IPrivateFileReference file) /// public async ValueTask ReadAsync(IPrivateFileReference file) { - Internal.AzureFileReference fileReference = await this.InternalGetAsync(file); + Internal.AzureBlobsFileReference fileReference = await this.InternalGetAsync(file); return await fileReference.ReadInMemoryAsync(); } @@ -175,7 +175,7 @@ public async ValueTask ReadAsync(IPrivateFileReference file) /// public async ValueTask ReadAllBytesAsync(IPrivateFileReference file) { - Internal.AzureFileReference fileReference = await this.InternalGetAsync(file); + Internal.AzureBlobsFileReference fileReference = await this.InternalGetAsync(file); return await fileReference.ReadAllBytesAsync(); } @@ -188,7 +188,7 @@ public async ValueTask ReadAllBytesAsync(IPrivateFileReference file) /// public async ValueTask ReadAllTextAsync(IPrivateFileReference file) { - Internal.AzureFileReference fileReference = await this.InternalGetAsync(file); + Internal.AzureBlobsFileReference fileReference = await this.InternalGetAsync(file); return await fileReference.ReadAllTextAsync(); } @@ -281,7 +281,7 @@ public async ValueTask SaveAsync(Stream data, IPrivateFileRefere Response refreshedProperties = await blobClient.GetPropertiesAsync(); - return new Internal.AzureFileReference(blobClient, new Internal.AzureFileProperties(blobClient, refreshedProperties)); + return new Internal.AzureBlobsFileReference(blobClient, new Internal.AzureBlobsFileProperties(blobClient, refreshedProperties)); } /// @@ -335,12 +335,12 @@ private static BlobContainerSasPermissions FromGenericToAzure(SharedAccessPermis return result; } - private ValueTask InternalGetAsync(IPrivateFileReference file, bool withMetadata = false) + private ValueTask InternalGetAsync(IPrivateFileReference file, bool withMetadata = false) { return this.InternalGetAsync(new Uri(file.Path, UriKind.Relative), withMetadata); } - private async ValueTask InternalGetAsync(Uri uri, bool withMetadata) + private async ValueTask InternalGetAsync(Uri uri, bool withMetadata) { try { @@ -359,14 +359,14 @@ private static BlobContainerSasPermissions FromGenericToAzure(SharedAccessPermis return null; } - Internal.AzureFileProperties properties = null; + Internal.AzureBlobsFileProperties properties = null; if (withMetadata) { Response blobProperties = await blobClient.GetPropertiesAsync(); - properties = new Internal.AzureFileProperties(blobClient, blobProperties); + properties = new Internal.AzureBlobsFileProperties(blobClient, blobProperties); } - return new Internal.AzureFileReference(blobClient, properties); + return new Internal.AzureBlobsFileReference(blobClient, properties); } catch (RequestFailedException ex) when (ex.ErrorCode == BlobErrorCode.BlobNotFound) { diff --git a/src/Proffer.Storage.Azure/Configuration/AzureParsedOptions.cs b/src/Proffer.Storage.Azure.Blobs/Configuration/AzureBlobsParsedOptions.cs similarity index 77% rename from src/Proffer.Storage.Azure/Configuration/AzureParsedOptions.cs rename to src/Proffer.Storage.Azure.Blobs/Configuration/AzureBlobsParsedOptions.cs index 7d795d0..91bc8e0 100644 --- a/src/Proffer.Storage.Azure/Configuration/AzureParsedOptions.cs +++ b/src/Proffer.Storage.Azure.Blobs/Configuration/AzureBlobsParsedOptions.cs @@ -1,18 +1,18 @@ -namespace Proffer.Storage.Azure.Configuration +namespace Proffer.Storage.Azure.Blobs.Configuration { using System.Collections.Generic; using Proffer.Storage.Configuration; /// - /// Typed Azure Storage options parsed from the dynamic configuration. + /// Typed Azure Blobs options parsed from the dynamic configuration. /// /// - public class AzureParsedOptions : IParsedOptions + public class AzureBlobsParsedOptions : IParsedOptions { /// /// Gets the name. /// - public string Name => AzureStorageProvider.ProviderName; + public string Name => AzureBlobsStorageProvider.ProviderName; /// /// Gets or sets the connection strings. @@ -22,24 +22,24 @@ public class AzureParsedOptions : IParsedOptions /// Gets or sets the parsed provider instances options. /// - public IReadOnlyDictionary ParsedProviderInstances { get; set; } + public IReadOnlyDictionary ParsedProviderInstances { get; set; } /// /// Gets or sets the parsed stores options. /// - public IReadOnlyDictionary ParsedStores { get; set; } + public IReadOnlyDictionary ParsedStores { get; set; } /// /// Gets or sets the parsed scoped stores options. /// - public IReadOnlyDictionary ParsedScopedStores { get; set; } + public IReadOnlyDictionary ParsedScopedStores { get; set; } /// /// Binds the provider instance options. /// /// The provider instance options. /// - public void BindProviderInstanceOptions(AzureProviderInstanceOptions providerInstanceOptions) + public void BindProviderInstanceOptions(AzureBlobsProviderInstanceOptions providerInstanceOptions) { if (!string.IsNullOrEmpty(providerInstanceOptions.ConnectionStringName) && string.IsNullOrEmpty(providerInstanceOptions.ConnectionString)) @@ -61,7 +61,7 @@ public void BindProviderInstanceOptions(AzureProviderInstanceOptions providerIns /// The store options. /// The provider instance options. /// - public void BindStoreOptions(AzureStoreOptions storeOptions, AzureProviderInstanceOptions providerInstanceOptions = null) + public void BindStoreOptions(AzureBlobsStoreOptions storeOptions, AzureBlobsProviderInstanceOptions providerInstanceOptions = null) { storeOptions.FolderName = storeOptions.FolderName.ToLowerInvariant(); @@ -71,7 +71,7 @@ public void BindStoreOptions(AzureStoreOptions storeOptions, AzureProviderInstan if (!this.ConnectionStrings.ContainsKey(storeOptions.ConnectionStringName)) { throw new Exceptions.BadStoreConfiguration( - storeOptions.Name, + storeOptions.Name, $"The ConnectionString '{storeOptions.ConnectionStringName}' cannot be found. Did you call AddStorage with the ConfigurationRoot?"); } diff --git a/src/Proffer.Storage.Azure/Configuration/AzureProviderInstanceOptions.cs b/src/Proffer.Storage.Azure.Blobs/Configuration/AzureBlobsProviderInstanceOptions.cs similarity index 69% rename from src/Proffer.Storage.Azure/Configuration/AzureProviderInstanceOptions.cs rename to src/Proffer.Storage.Azure.Blobs/Configuration/AzureBlobsProviderInstanceOptions.cs index 77ff197..8b9f9a8 100644 --- a/src/Proffer.Storage.Azure/Configuration/AzureProviderInstanceOptions.cs +++ b/src/Proffer.Storage.Azure.Blobs/Configuration/AzureBlobsProviderInstanceOptions.cs @@ -1,12 +1,12 @@ -namespace Proffer.Storage.Azure.Configuration +namespace Proffer.Storage.Azure.Blobs.Configuration { using Proffer.Storage.Configuration; /// - /// Options for an instance of . + /// Options for an instance of . /// /// - public class AzureProviderInstanceOptions : ProviderInstanceOptions + public class AzureBlobsProviderInstanceOptions : ProviderInstanceOptions { /// /// Gets or sets the connection string. diff --git a/src/Proffer.Storage.Azure/Configuration/AzureScopedStoreOptions.cs b/src/Proffer.Storage.Azure.Blobs/Configuration/AzureBlobsScopedStoreOptions.cs similarity index 52% rename from src/Proffer.Storage.Azure/Configuration/AzureScopedStoreOptions.cs rename to src/Proffer.Storage.Azure.Blobs/Configuration/AzureBlobsScopedStoreOptions.cs index 061af03..c9517a1 100644 --- a/src/Proffer.Storage.Azure/Configuration/AzureScopedStoreOptions.cs +++ b/src/Proffer.Storage.Azure.Blobs/Configuration/AzureBlobsScopedStoreOptions.cs @@ -1,13 +1,13 @@ -namespace Proffer.Storage.Azure.Configuration +namespace Proffer.Storage.Azure.Blobs.Configuration { using Proffer.Storage.Configuration; /// - /// Options for a scoped . + /// Options for a scoped . /// - /// + /// /// - public class AzureScopedStoreOptions : AzureStoreOptions, IScopedStoreOptions + public class AzureBlobsScopedStoreOptions : AzureBlobsStoreOptions, IScopedStoreOptions { /// /// Gets the folder name format. diff --git a/src/Proffer.Storage.Azure/Configuration/AzureStoreOptions.cs b/src/Proffer.Storage.Azure.Blobs/Configuration/AzureBlobsStoreOptions.cs similarity index 91% rename from src/Proffer.Storage.Azure/Configuration/AzureStoreOptions.cs rename to src/Proffer.Storage.Azure.Blobs/Configuration/AzureBlobsStoreOptions.cs index 045dd92..2521fd7 100644 --- a/src/Proffer.Storage.Azure/Configuration/AzureStoreOptions.cs +++ b/src/Proffer.Storage.Azure.Blobs/Configuration/AzureBlobsStoreOptions.cs @@ -1,14 +1,14 @@ -namespace Proffer.Storage.Azure.Configuration +namespace Proffer.Storage.Azure.Blobs.Configuration { using System.Collections.Generic; using System.Linq; using Proffer.Storage.Configuration; /// - /// Options for an . + /// Options for an . /// /// - public class AzureStoreOptions : StoreOptions + public class AzureBlobsStoreOptions : StoreOptions { /// /// Gets or sets the connection string. diff --git a/src/Proffer.Storage.Azure/Internal/AzureFileProperties.cs b/src/Proffer.Storage.Azure.Blobs/Internal/AzureBlobsFileProperties.cs similarity index 89% rename from src/Proffer.Storage.Azure/Internal/AzureFileProperties.cs rename to src/Proffer.Storage.Azure.Blobs/Internal/AzureBlobsFileProperties.cs index 7c74b8e..2a574e8 100644 --- a/src/Proffer.Storage.Azure/Internal/AzureFileProperties.cs +++ b/src/Proffer.Storage.Azure.Blobs/Internal/AzureBlobsFileProperties.cs @@ -1,4 +1,4 @@ -namespace Proffer.Storage.Azure.Internal +namespace Proffer.Storage.Azure.Blobs.Internal { using System; using System.Collections.Generic; @@ -10,10 +10,10 @@ namespace Proffer.Storage.Azure.Internal using global::Azure.Storage.Blobs.Models; /// - /// File common properties with metadata stored on Azure Storage. + /// File common properties with metadata stored on Azure Blobs. /// /// - public class AzureFileProperties : IFileProperties + public class AzureBlobsFileProperties : IFileProperties { private const string DefaultCacheControl = "max-age=300, must-revalidate"; private readonly BlobClient blobClient; @@ -21,22 +21,22 @@ public class AzureFileProperties : IFileProperties private Dictionary decodedMetadata; /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// - /// The Azure Storage blob client. + /// The Azure Blobs client. /// The blob properties. - public AzureFileProperties(BlobClient blobClient, BlobProperties blobProperties) + public AzureBlobsFileProperties(BlobClient blobClient, BlobProperties blobProperties) { this.blobClient = blobClient; this.ExtractProperties(blobProperties); } /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// - /// The Azure Storage blob client. + /// The Azure Blobs client. /// The blob item from listing. - public AzureFileProperties(BlobClient blobClient, BlobItem blobItem) + public AzureBlobsFileProperties(BlobClient blobClient, BlobItem blobItem) { this.blobClient = blobClient; this.ExtractProperties(blobItem); diff --git a/src/Proffer.Storage.Azure/Internal/AzureFileReference.cs b/src/Proffer.Storage.Azure.Blobs/Internal/AzureBlobsFileReference.cs similarity index 89% rename from src/Proffer.Storage.Azure/Internal/AzureFileReference.cs rename to src/Proffer.Storage.Azure.Blobs/Internal/AzureBlobsFileReference.cs index 10c0b79..cd0d62a 100644 --- a/src/Proffer.Storage.Azure/Internal/AzureFileReference.cs +++ b/src/Proffer.Storage.Azure.Blobs/Internal/AzureBlobsFileReference.cs @@ -1,4 +1,4 @@ -namespace Proffer.Storage.Azure.Internal +namespace Proffer.Storage.Azure.Blobs.Internal { using System; using System.IO; @@ -9,28 +9,28 @@ namespace Proffer.Storage.Azure.Internal using global::Azure.Storage.Sas; /// - /// A reference of a stored file at a given path on Azure Storage. + /// A reference of a stored file at a given path on Azure Blobs. /// /// - public class AzureFileReference : IFileReference + public class AzureBlobsFileReference : IFileReference { private readonly BlobClient blobClient; - private Lazy propertiesLazy; + private Lazy propertiesLazy; private bool withMetadata; /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// - /// The Azure Storage blob client. + /// The Azure Blobs client. /// The properties, if fetched. - public AzureFileReference(BlobClient blobClient, AzureFileProperties properties = null) + public AzureBlobsFileReference(BlobClient blobClient, AzureBlobsFileProperties properties = null) { this.blobClient = blobClient; this.withMetadata = properties != null; this.Path = blobClient.Name; - this.propertiesLazy = new Lazy(() => + this.propertiesLazy = new Lazy(() => { if (this.withMetadata) { @@ -156,7 +156,7 @@ public async Task FetchProperties() Response refreshedProperties = await this.blobClient.GetPropertiesAsync(); - this.propertiesLazy = new Lazy(() => new AzureFileProperties(this.blobClient, refreshedProperties)); + this.propertiesLazy = new Lazy(() => new AzureBlobsFileProperties(this.blobClient, refreshedProperties)); this.withMetadata = true; } diff --git a/src/Proffer.Storage.Azure/Internal/AzureListDirectoryWrapper.cs b/src/Proffer.Storage.Azure.Blobs/Internal/AzureBlobsListDirectoryWrapper.cs similarity index 79% rename from src/Proffer.Storage.Azure/Internal/AzureListDirectoryWrapper.cs rename to src/Proffer.Storage.Azure.Blobs/Internal/AzureBlobsListDirectoryWrapper.cs index 7093cd9..cd737fb 100644 --- a/src/Proffer.Storage.Azure/Internal/AzureListDirectoryWrapper.cs +++ b/src/Proffer.Storage.Azure.Blobs/Internal/AzureBlobsListDirectoryWrapper.cs @@ -1,4 +1,4 @@ -namespace Proffer.Storage.Azure.Internal +namespace Proffer.Storage.Azure.Blobs.Internal { using System; using System.Collections.Generic; @@ -6,33 +6,33 @@ namespace Proffer.Storage.Azure.Internal using Microsoft.Extensions.FileSystemGlobbing.Abstractions; /// - /// Represents a directory in a being-listed . + /// Represents a directory in a being-listed . /// /// - public class AzureListDirectoryWrapper : DirectoryInfoBase + public class AzureBlobsListDirectoryWrapper : DirectoryInfoBase { private readonly string name; private readonly string fullName; private readonly string path; - private readonly Dictionary files; + private readonly Dictionary files; /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The childrens. [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0060:Remove unused parameter", Justification = "FileSystemGlobbing abstractions")] - public AzureListDirectoryWrapper(FileSystemInfoBase childrens) + public AzureBlobsListDirectoryWrapper(FileSystemInfoBase childrens) { this.fullName = "root"; this.ParentDirectory = null; } /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The directory path. /// The files. - public AzureListDirectoryWrapper(string path, Dictionary files) + public AzureBlobsListDirectoryWrapper(string path, Dictionary files) { this.path = path ?? ""; this.files = files; @@ -64,7 +64,7 @@ public AzureListDirectoryWrapper(string path, Dictionary public override IEnumerable EnumerateFileSystemInfos() - => this.files.Values.Select(file => new AzureListFileWrapper(file, this)); + => this.files.Values.Select(file => new AzureBlobsListFileWrapper(file, this)); /// /// Returns an instance of that represents a subdirectory. @@ -83,6 +83,6 @@ public override IEnumerable EnumerateFileSystemInfos() /// /// Instance of even if file does not exist /// - public override FileInfoBase GetFile(string path) => new AzureListFileWrapper(this.files[path], this); + public override FileInfoBase GetFile(string path) => new AzureBlobsListFileWrapper(this.files[path], this); } } diff --git a/src/Proffer.Storage.Azure/Internal/AzureListFileWrapper.cs b/src/Proffer.Storage.Azure.Blobs/Internal/AzureBlobsListFileWrapper.cs similarity index 53% rename from src/Proffer.Storage.Azure/Internal/AzureListFileWrapper.cs rename to src/Proffer.Storage.Azure.Blobs/Internal/AzureBlobsListFileWrapper.cs index 067b1c7..19f51a8 100644 --- a/src/Proffer.Storage.Azure/Internal/AzureListFileWrapper.cs +++ b/src/Proffer.Storage.Azure.Blobs/Internal/AzureBlobsListFileWrapper.cs @@ -1,28 +1,28 @@ -namespace Proffer.Storage.Azure.Internal +namespace Proffer.Storage.Azure.Blobs.Internal { using Microsoft.Extensions.FileSystemGlobbing.Abstractions; /// - /// Represents a file in a being-listed . + /// Represents a file in a being-listed . /// /// - public class AzureListFileWrapper : FileInfoBase + public class AzureBlobsListFileWrapper : FileInfoBase { - private readonly AzureFileReference blob; + private readonly AzureBlobsFileReference blob; private readonly string name; - private readonly AzureListDirectoryWrapper parent; + private readonly AzureBlobsListDirectoryWrapper parent; /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// - /// The Azure Storage blob. + /// The file reference. /// The parent directory. - public AzureListFileWrapper(AzureFileReference blob, AzureListDirectoryWrapper parent) + public AzureBlobsListFileWrapper(AzureBlobsFileReference file, AzureBlobsListDirectoryWrapper parent) { - this.blob = blob; - int lastSlash = blob.Path.LastIndexOf('/'); + this.blob = file; + int lastSlash = file.Path.LastIndexOf('/'); - this.name = lastSlash >= 0 ? blob.Path.Substring(lastSlash + 1) : blob.Path; + this.name = lastSlash >= 0 ? file.Path.Substring(lastSlash + 1) : file.Path; this.parent = parent; } diff --git a/src/Proffer.Storage.Azure/Proffer.Storage.Azure.csproj b/src/Proffer.Storage.Azure.Blobs/Proffer.Storage.Azure.Blobs.csproj similarity index 75% rename from src/Proffer.Storage.Azure/Proffer.Storage.Azure.csproj rename to src/Proffer.Storage.Azure.Blobs/Proffer.Storage.Azure.Blobs.csproj index c7d92c6..978f54c 100644 --- a/src/Proffer.Storage.Azure/Proffer.Storage.Azure.csproj +++ b/src/Proffer.Storage.Azure.Blobs/Proffer.Storage.Azure.Blobs.csproj @@ -1,9 +1,9 @@ - + - Proffer.Storage.Azure - Proffer.Storage.Azure - Azure Storage provider for Proffer.Storage abstractions. + Proffer.Storage.Azure.Blobs + Proffer.Storage.Azure.Blobs + Azure Blobs provider for Proffer.Storage abstractions. Proffer Adrien Siffermann https://github.com/asiffermann/proffer diff --git a/src/Proffer.Storage.FileSystem/FileSystemStorageServiceCollectionExtensions.cs b/src/Proffer.Storage.FileSystem/FileSystemStorageServiceCollectionExtensions.cs index 7c6ec3c..3291bd1 100644 --- a/src/Proffer.Storage.FileSystem/FileSystemStorageServiceCollectionExtensions.cs +++ b/src/Proffer.Storage.FileSystem/FileSystemStorageServiceCollectionExtensions.cs @@ -32,7 +32,7 @@ public static IServiceCollection AddFileSystemStorage(this IServiceCollection se /// The service collection. public static IServiceCollection AddFileSystemStorage(this IServiceCollection services) { - return services + return services .Configure(options => options.RootPath = System.IO.Directory.GetCurrentDirectory()) .AddFileSystemStorageServices(); } diff --git a/src/Proffer.Storage.FileSystem/FileSystemStore.cs b/src/Proffer.Storage.FileSystem/FileSystemStore.cs index 0f5f69c..f13f870 100644 --- a/src/Proffer.Storage.FileSystem/FileSystemStore.cs +++ b/src/Proffer.Storage.FileSystem/FileSystemStore.cs @@ -1,6 +1,5 @@ namespace Proffer.Storage.FileSystem { - using Proffer.Storage.FileSystem.Configuration; using System; using System.Collections.Generic; using System.IO; @@ -8,6 +7,7 @@ namespace Proffer.Storage.FileSystem using System.Security.Cryptography; using System.Threading; using System.Threading.Tasks; + using Proffer.Storage.FileSystem.Configuration; /// /// A File System store allows to save, list or read files on a container in its configured . @@ -71,7 +71,7 @@ public Task InitAsync(CancellationToken cancellationToken = default) /// public async ValueTask ListAsync(string path, bool recursive, bool withMetadata) { - string directoryPath = (string.IsNullOrEmpty(path) || path == "/" || path == "\\") ? this.AbsolutePath : Path.Combine(this.AbsolutePath, path); + string directoryPath = ( string.IsNullOrEmpty(path) || path == "/" || path == "\\" ) ? this.AbsolutePath : Path.Combine(this.AbsolutePath, path); var result = new List(); if (Directory.Exists(directoryPath)) @@ -101,7 +101,7 @@ public async ValueTask ListAsync(string path, bool recursive, /// public async ValueTask ListAsync(string path, string searchPattern, bool recursive, bool withMetadata) { - string directoryPath = (string.IsNullOrEmpty(path) || path == "/" || path == "\\") ? this.AbsolutePath : Path.Combine(this.AbsolutePath, path); + string directoryPath = ( string.IsNullOrEmpty(path) || path == "/" || path == "\\" ) ? this.AbsolutePath : Path.Combine(this.AbsolutePath, path); var result = new List(); if (Directory.Exists(directoryPath)) @@ -251,9 +251,9 @@ public async ValueTask SaveAsync(Stream data, IPrivateFileRefere var properties = fileReference.Properties as Internal.FileSystemFileProperties; (string ETag, string ContentMD5) = ComputeHashes(data); - if (!fileExists + if (!fileExists || overwritePolicy == OverwritePolicy.Always - || (overwritePolicy == OverwritePolicy.IfContentModified && properties.ContentMD5 != ContentMD5)) + || ( overwritePolicy == OverwritePolicy.IfContentModified && properties.ContentMD5 != ContentMD5 )) { this.EnsurePathExists(fileReference.FileSystemPath); diff --git a/src/Proffer.Storage.FileSystem/Internal/FileSystemFileReference.cs b/src/Proffer.Storage.FileSystem/Internal/FileSystemFileReference.cs index 6b8f974..8ec9132 100644 --- a/src/Proffer.Storage.FileSystem/Internal/FileSystemFileReference.cs +++ b/src/Proffer.Storage.FileSystem/Internal/FileSystemFileReference.cs @@ -161,7 +161,7 @@ public Task SavePropertiesAsync() return this.extendedPropertiesProvider.SaveExtendedPropertiesAsync( this.store.AbsolutePath, this, - (this.Properties as FileSystemFileProperties).ExtendedProperties); + ( this.Properties as FileSystemFileProperties ).ExtendedProperties); } /// diff --git a/src/Proffer.Storage/Configuration/ConfigurationExtensions.cs b/src/Proffer.Storage/Configuration/ConfigurationExtensions.cs index 644df96..c9ddeca 100644 --- a/src/Proffer.Storage/Configuration/ConfigurationExtensions.cs +++ b/src/Proffer.Storage/Configuration/ConfigurationExtensions.cs @@ -160,7 +160,7 @@ public static TStoreOptions ParseStoreOptions ReadAllTextAsync(this IStore store, string path) /// The saved . /// /// - public static ValueTask SaveAsync(this IStore store, byte[] data, string path, string contentType, OverwritePolicy overwritePolicy = OverwritePolicy.Always, IDictionary metadata = null) + public static ValueTask SaveAsync(this IStore store, byte[] data, string path, string contentType, OverwritePolicy overwritePolicy = OverwritePolicy.Always, IDictionary metadata = null) => store.SaveAsync(data, new Internal.PrivateFileReference(path), contentType, overwritePolicy, metadata); /// @@ -121,7 +121,7 @@ public static ValueTask SaveAsync(this IStore store, byte[] data /// The saved . /// /// - public static ValueTask SaveAsync(this IStore store, Stream data, string path, string contentType, OverwritePolicy overwritePolicy = OverwritePolicy.Always, IDictionary metadata = null) + public static ValueTask SaveAsync(this IStore store, Stream data, string path, string contentType, OverwritePolicy overwritePolicy = OverwritePolicy.Always, IDictionary metadata = null) => store.SaveAsync(data, new Internal.PrivateFileReference(path), contentType, overwritePolicy, metadata); } } diff --git a/src/Proffer.Storage/Internal/ConfigureProviderOptions.cs b/src/Proffer.Storage/Internal/ConfigureProviderOptions.cs index 39e5411..1c9d53b 100644 --- a/src/Proffer.Storage/Internal/ConfigureProviderOptions.cs +++ b/src/Proffer.Storage/Internal/ConfigureProviderOptions.cs @@ -1,9 +1,9 @@ namespace Proffer.Storage.Internal { - using Proffer.Storage.Configuration; - using Microsoft.Extensions.Options; - using System.Linq; using System.Collections.Generic; + using System.Linq; + using Microsoft.Extensions.Options; + using Proffer.Storage.Configuration; /// /// Configures a provider from generic . diff --git a/src/Proffer.Storage/Internal/GenericStoreProxy.cs b/src/Proffer.Storage/Internal/GenericStoreProxy.cs index cb16379..70502ff 100644 --- a/src/Proffer.Storage/Internal/GenericStoreProxy.cs +++ b/src/Proffer.Storage/Internal/GenericStoreProxy.cs @@ -1,13 +1,13 @@ namespace Proffer.Storage.Internal { - using Configuration; - using Dawn; - using Microsoft.Extensions.Options; using System; using System.Collections.Generic; using System.IO; using System.Threading; using System.Threading.Tasks; + using Configuration; + using Dawn; + using Microsoft.Extensions.Options; /// /// Generic proxy to allow direct dependency injection of a . diff --git a/src/Proffer.Storage/Internal/StorageFactory.cs b/src/Proffer.Storage/Internal/StorageFactory.cs index 2bfdf50..7af2960 100644 --- a/src/Proffer.Storage/Internal/StorageFactory.cs +++ b/src/Proffer.Storage/Internal/StorageFactory.cs @@ -1,9 +1,9 @@ namespace Proffer.Storage.Internal { - using Proffer.Storage.Configuration; - using Microsoft.Extensions.Options; using System.Collections.Generic; using System.Linq; + using Microsoft.Extensions.Options; + using Proffer.Storage.Configuration; /// /// Default storage factory to build from configured . @@ -171,6 +171,6 @@ private IStorageProvider GetProvider(IStoreOptions configuration, bool throwIfNo } return provider; - } + } } } diff --git a/src/Proffer.Storage/Internal/StorageProviderBase.cs b/src/Proffer.Storage/Internal/StorageProviderBase.cs index 1618053..65a5fa3 100644 --- a/src/Proffer.Storage/Internal/StorageProviderBase.cs +++ b/src/Proffer.Storage/Internal/StorageProviderBase.cs @@ -61,7 +61,7 @@ public IStore BuildStore(string storeName) public IStore BuildStore(string storeName, IStoreOptions storeOptions) { return this.BuildStoreInternal( - storeName, + storeName, storeOptions.ParseStoreOptions(this.Options)); } diff --git a/tests/Proffer.Email.SendGrid.Tests/Proffer.Email.SendGrid.Tests.csproj b/tests/Proffer.Email.SendGrid.Tests/Proffer.Email.SendGrid.Tests.csproj index 7ced86d..b5637fb 100644 --- a/tests/Proffer.Email.SendGrid.Tests/Proffer.Email.SendGrid.Tests.csproj +++ b/tests/Proffer.Email.SendGrid.Tests/Proffer.Email.SendGrid.Tests.csproj @@ -29,7 +29,7 @@ - + diff --git a/tests/Proffer.Storage.Azure.Tests/Abstract/ConfiguredStoresTestsBase.cs b/tests/Proffer.Storage.Azure.Blobs.Tests/Abstract/ConfiguredStoresTestsBase.cs similarity index 93% rename from tests/Proffer.Storage.Azure.Tests/Abstract/ConfiguredStoresTestsBase.cs rename to tests/Proffer.Storage.Azure.Blobs.Tests/Abstract/ConfiguredStoresTestsBase.cs index 644b7f7..a7dc1d3 100644 --- a/tests/Proffer.Storage.Azure.Tests/Abstract/ConfiguredStoresTestsBase.cs +++ b/tests/Proffer.Storage.Azure.Blobs.Tests/Abstract/ConfiguredStoresTestsBase.cs @@ -1,4 +1,4 @@ -namespace Proffer.Storage.Azure.Tests.Abstract +namespace Proffer.Storage.Azure.Blobs.Tests.Abstract { using Xunit; diff --git a/tests/Proffer.Storage.Azure.Blobs.Tests/AzureBlobsCollection.cs b/tests/Proffer.Storage.Azure.Blobs.Tests/AzureBlobsCollection.cs new file mode 100644 index 0000000..5afffe8 --- /dev/null +++ b/tests/Proffer.Storage.Azure.Blobs.Tests/AzureBlobsCollection.cs @@ -0,0 +1,7 @@ +namespace Proffer.Storage.Azure.Blobs.Tests +{ + using Xunit; + + [CollectionDefinition(nameof(AzureBlobsCollection))] + public class AzureBlobsCollection : ICollectionFixture { } +} diff --git a/tests/Proffer.Storage.Azure.Tests/AzureFixture.cs b/tests/Proffer.Storage.Azure.Blobs.Tests/AzureBlobsFixture.cs similarity index 83% rename from tests/Proffer.Storage.Azure.Tests/AzureFixture.cs rename to tests/Proffer.Storage.Azure.Blobs.Tests/AzureBlobsFixture.cs index f7de945..30a7218 100644 --- a/tests/Proffer.Storage.Azure.Tests/AzureFixture.cs +++ b/tests/Proffer.Storage.Azure.Blobs.Tests/AzureBlobsFixture.cs @@ -1,4 +1,4 @@ -namespace Proffer.Storage.Azure.Tests +namespace Proffer.Storage.Azure.Blobs.Tests { using System; using System.Collections.Generic; @@ -10,26 +10,26 @@ namespace Proffer.Storage.Azure.Tests using global::Azure.Storage.Sas; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Options; - using Proffer.Storage.Azure.Configuration; - using Proffer.Storage.Azure.Tests.Stubs; + using Proffer.Storage.Azure.Blobs.Configuration; + using Proffer.Storage.Azure.Blobs.Tests.Stubs; using Proffer.Storage.Configuration; using Proffer.Testing; using Storage; - public class AzureFixture : ServiceProviderFixtureBase + public class AzureBlobsFixture : ServiceProviderFixtureBase { - public AzureFixture() + public AzureBlobsFixture() { - this.ParsedOptions = this.Services.GetService>().Value; - this.GenericStoreOptions = this.Services.GetService>().Value - .ParseStoreOptions(this.ParsedOptions); + this.ParsedOptions = this.Services.GetService>().Value; + this.GenericStoreOptions = this.Services.GetService>().Value + .ParseStoreOptions(this.ParsedOptions); this.InitStores(); } - public AzureParsedOptions ParsedOptions { get; } + public AzureBlobsParsedOptions ParsedOptions { get; } - public AzureStoreOptions GenericStoreOptions { get; } + public AzureBlobsStoreOptions GenericStoreOptions { get; } private string AzCopy => Environment.ExpandEnvironmentVariables(this.Configuration["AzCopy10Command"]); @@ -63,12 +63,12 @@ protected override void ConfigureServices(IServiceCollection services) .AddStorage(this.Configuration) .AddAzureStorage(); - services.Configure(o => o.ConnectionString = this.ConnectionString); + services.Configure(o => o.ConnectionString = this.ConnectionString); } protected override void OnDispose() { - foreach (KeyValuePair parsedStoreKvp in this.ParsedOptions.ParsedStores) + foreach (KeyValuePair parsedStoreKvp in this.ParsedOptions.ParsedStores) { var containerClient = new BlobContainerClient(this.ConnectionString, parsedStoreKvp.Value.FolderName); containerClient.Delete(); @@ -78,13 +78,13 @@ protected override void OnDispose() private void InitStores() { this.InitStore(this.GenericStoreOptions); - foreach (KeyValuePair parsedStoreKvp in this.ParsedOptions.ParsedStores) + foreach (KeyValuePair parsedStoreKvp in this.ParsedOptions.ParsedStores) { this.InitStore(parsedStoreKvp.Value); } } - private void InitStore(AzureStoreOptions storeOptions) + private void InitStore(AzureBlobsStoreOptions storeOptions) { var containerClient = new BlobContainerClient(storeOptions.ConnectionString, storeOptions.FolderName); containerClient.CreateIfNotExists(); diff --git a/tests/Proffer.Storage.Azure.Tests/DeleteTests.cs b/tests/Proffer.Storage.Azure.Blobs.Tests/DeleteTests.cs similarity index 87% rename from tests/Proffer.Storage.Azure.Tests/DeleteTests.cs rename to tests/Proffer.Storage.Azure.Blobs.Tests/DeleteTests.cs index 5632d64..b50d594 100644 --- a/tests/Proffer.Storage.Azure.Tests/DeleteTests.cs +++ b/tests/Proffer.Storage.Azure.Blobs.Tests/DeleteTests.cs @@ -1,4 +1,4 @@ -namespace Proffer.Storage.Azure.Tests +namespace Proffer.Storage.Azure.Blobs.Tests { using System.Threading.Tasks; using Storage; @@ -9,12 +9,12 @@ namespace Proffer.Storage.Azure.Tests [Feature(nameof(Storage))] [Feature(nameof(Azure))] [Feature(nameof(IFileReference.DeleteAsync))] - [Collection(nameof(AzureCollection))] + [Collection(nameof(AzureBlobsCollection))] public class DeleteTests : Abstract.ConfiguredStoresTestsBase { - private readonly AzureFixture fixture; + private readonly AzureBlobsFixture fixture; - public DeleteTests(AzureFixture fixture) + public DeleteTests(AzureBlobsFixture fixture) { this.fixture = fixture; } diff --git a/tests/Proffer.Storage.Azure.Tests/GenericStoreTests.cs b/tests/Proffer.Storage.Azure.Blobs.Tests/GenericStoreTests.cs similarity index 70% rename from tests/Proffer.Storage.Azure.Tests/GenericStoreTests.cs rename to tests/Proffer.Storage.Azure.Blobs.Tests/GenericStoreTests.cs index c70f6eb..9166055 100644 --- a/tests/Proffer.Storage.Azure.Tests/GenericStoreTests.cs +++ b/tests/Proffer.Storage.Azure.Blobs.Tests/GenericStoreTests.cs @@ -1,9 +1,9 @@ -namespace Proffer.Storage.Azure.Tests +namespace Proffer.Storage.Azure.Blobs.Tests { using System.Linq; using System.Threading.Tasks; using Microsoft.Extensions.DependencyInjection; - using Proffer.Storage.Azure.Tests.Stubs; + using Proffer.Storage.Azure.Blobs.Tests.Stubs; using Storage; using Xunit; using Xunit.Categories; @@ -12,12 +12,12 @@ namespace Proffer.Storage.Azure.Tests [Feature(nameof(Storage))] [Feature(nameof(Azure))] [Feature("IStore")] - [Collection(nameof(AzureCollection))] + [Collection(nameof(AzureBlobsCollection))] public class GenericStoreTests { - private readonly AzureFixture fixture; + private readonly AzureBlobsFixture fixture; - public GenericStoreTests(AzureFixture fixture) + public GenericStoreTests(AzureBlobsFixture fixture) { this.fixture = fixture; } @@ -25,7 +25,7 @@ public GenericStoreTests(AzureFixture fixture) [Fact] public async Task Should_ListFiles_With_GenericStore() { - IStore store = this.fixture.Services.GetRequiredService>(); + IStore store = this.fixture.Services.GetRequiredService>(); string[] expected = new string[] { "TextFile.txt", "template.hbs" }; diff --git a/tests/Proffer.Storage.Azure.Tests/GetScopedStoreTests.cs b/tests/Proffer.Storage.Azure.Blobs.Tests/GetScopedStoreTests.cs similarity index 83% rename from tests/Proffer.Storage.Azure.Tests/GetScopedStoreTests.cs rename to tests/Proffer.Storage.Azure.Blobs.Tests/GetScopedStoreTests.cs index 47ffec1..b596a12 100644 --- a/tests/Proffer.Storage.Azure.Tests/GetScopedStoreTests.cs +++ b/tests/Proffer.Storage.Azure.Blobs.Tests/GetScopedStoreTests.cs @@ -1,4 +1,4 @@ -namespace Proffer.Storage.Azure.Tests +namespace Proffer.Storage.Azure.Blobs.Tests { using System.Text; using System.Threading.Tasks; @@ -10,12 +10,12 @@ namespace Proffer.Storage.Azure.Tests [Feature(nameof(Storage))] [Feature(nameof(Azure))] [Feature(nameof(IStorageFactory.GetScopedStore))] - [Collection(nameof(AzureCollection))] + [Collection(nameof(AzureBlobsCollection))] public class GetScopedStoreTests : Abstract.ConfiguredStoresTestsBase { - private readonly AzureFixture fixture; + private readonly AzureBlobsFixture fixture; - public GetScopedStoreTests(AzureFixture fixture) + public GetScopedStoreTests(AzureBlobsFixture fixture) { this.fixture = fixture; } diff --git a/tests/Proffer.Storage.Azure.Tests/GetSharedAccessSignatureTests.cs b/tests/Proffer.Storage.Azure.Blobs.Tests/GetSharedAccessSignatureTests.cs similarity index 81% rename from tests/Proffer.Storage.Azure.Tests/GetSharedAccessSignatureTests.cs rename to tests/Proffer.Storage.Azure.Blobs.Tests/GetSharedAccessSignatureTests.cs index 49c6d51..b2de559 100644 --- a/tests/Proffer.Storage.Azure.Tests/GetSharedAccessSignatureTests.cs +++ b/tests/Proffer.Storage.Azure.Blobs.Tests/GetSharedAccessSignatureTests.cs @@ -1,4 +1,4 @@ -namespace Proffer.Storage.Azure.Tests +namespace Proffer.Storage.Azure.Blobs.Tests { using System; using System.Collections.Generic; @@ -8,7 +8,7 @@ namespace Proffer.Storage.Azure.Tests using global::Azure.Storage.Blobs.Models; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Options; - using Proffer.Storage.Azure.Configuration; + using Proffer.Storage.Azure.Blobs.Configuration; using Storage; using Xunit; using Xunit.Categories; @@ -17,12 +17,12 @@ namespace Proffer.Storage.Azure.Tests [Feature(nameof(Storage))] [Feature(nameof(Azure))] [Feature(nameof(IStore.GetSharedAccessSignatureAsync))] - [Collection(nameof(AzureCollection))] + [Collection(nameof(AzureBlobsCollection))] public class GetSharedAccessSignatureTests : Abstract.ConfiguredStoresTestsBase { - private readonly AzureFixture fixture; + private readonly AzureBlobsFixture fixture; - public GetSharedAccessSignatureTests(AzureFixture fixture) + public GetSharedAccessSignatureTests(AzureBlobsFixture fixture) { this.fixture = fixture; } @@ -31,11 +31,11 @@ public GetSharedAccessSignatureTests(AzureFixture fixture) public async Task Should_ListFiles_With_SharedAccessSignature(string storeName) { IStorageFactory storageFactory = this.fixture.Services.GetRequiredService(); - IOptions options = this.fixture.Services.GetRequiredService>(); + IOptions options = this.fixture.Services.GetRequiredService>(); IStore store = storageFactory.GetStore(storeName); - options.Value.ParsedStores.TryGetValue(storeName, out AzureStoreOptions storeOptions); + options.Value.ParsedStores.TryGetValue(storeName, out AzureBlobsStoreOptions storeOptions); var containerClientReference = new BlobContainerClient(storeOptions.ConnectionString, storeOptions.FolderName); string sharedAccessSignature = await store.GetSharedAccessSignatureAsync(new SharedAccessPolicy diff --git a/tests/Proffer.Storage.Azure.Tests/ListTests.cs b/tests/Proffer.Storage.Azure.Blobs.Tests/ListTests.cs similarity index 96% rename from tests/Proffer.Storage.Azure.Tests/ListTests.cs rename to tests/Proffer.Storage.Azure.Blobs.Tests/ListTests.cs index 0abbdc6..fde9f5d 100644 --- a/tests/Proffer.Storage.Azure.Tests/ListTests.cs +++ b/tests/Proffer.Storage.Azure.Blobs.Tests/ListTests.cs @@ -1,4 +1,4 @@ -namespace Proffer.Storage.Azure.Tests +namespace Proffer.Storage.Azure.Blobs.Tests { using System.Linq; using System.Threading.Tasks; @@ -10,12 +10,12 @@ namespace Proffer.Storage.Azure.Tests [Feature(nameof(Storage))] [Feature(nameof(Azure))] [Feature(nameof(IStore.ListAsync))] - [Collection(nameof(AzureCollection))] + [Collection(nameof(AzureBlobsCollection))] public class ListTests : Abstract.ConfiguredStoresTestsBase { - private readonly AzureFixture fixture; + private readonly AzureBlobsFixture fixture; - public ListTests(AzureFixture fixture) + public ListTests(AzureBlobsFixture fixture) { this.fixture = fixture; } diff --git a/tests/Proffer.Storage.Azure.Tests/Proffer.Storage.Azure.Tests.csproj b/tests/Proffer.Storage.Azure.Blobs.Tests/Proffer.Storage.Azure.Blobs.Tests.csproj similarity index 93% rename from tests/Proffer.Storage.Azure.Tests/Proffer.Storage.Azure.Tests.csproj rename to tests/Proffer.Storage.Azure.Blobs.Tests/Proffer.Storage.Azure.Blobs.Tests.csproj index fd02f1e..191f52a 100644 --- a/tests/Proffer.Storage.Azure.Tests/Proffer.Storage.Azure.Tests.csproj +++ b/tests/Proffer.Storage.Azure.Blobs.Tests/Proffer.Storage.Azure.Blobs.Tests.csproj @@ -26,7 +26,7 @@ - + diff --git a/tests/Proffer.Storage.Azure.Tests/ReadTests.cs b/tests/Proffer.Storage.Azure.Blobs.Tests/ReadTests.cs similarity index 97% rename from tests/Proffer.Storage.Azure.Tests/ReadTests.cs rename to tests/Proffer.Storage.Azure.Blobs.Tests/ReadTests.cs index 39f8f8c..b7338c7 100644 --- a/tests/Proffer.Storage.Azure.Tests/ReadTests.cs +++ b/tests/Proffer.Storage.Azure.Blobs.Tests/ReadTests.cs @@ -1,4 +1,4 @@ -namespace Proffer.Storage.Azure.Tests +namespace Proffer.Storage.Azure.Blobs.Tests { using System; using System.IO; @@ -10,12 +10,12 @@ namespace Proffer.Storage.Azure.Tests [IntegrationTest] [Feature(nameof(Storage))] [Feature(nameof(Azure))] - [Collection(nameof(AzureCollection))] + [Collection(nameof(AzureBlobsCollection))] public class ReadTests : Abstract.ConfiguredStoresTestsBase { - private readonly AzureFixture fixture; + private readonly AzureBlobsFixture fixture; - public ReadTests(AzureFixture fixture) + public ReadTests(AzureBlobsFixture fixture) { this.fixture = fixture; } diff --git a/tests/Proffer.Storage.Azure.Tests/SaveTests.cs b/tests/Proffer.Storage.Azure.Blobs.Tests/SaveTests.cs similarity index 97% rename from tests/Proffer.Storage.Azure.Tests/SaveTests.cs rename to tests/Proffer.Storage.Azure.Blobs.Tests/SaveTests.cs index 33828a8..6ca3f66 100644 --- a/tests/Proffer.Storage.Azure.Tests/SaveTests.cs +++ b/tests/Proffer.Storage.Azure.Blobs.Tests/SaveTests.cs @@ -1,10 +1,9 @@ -namespace Proffer.Storage.Azure.Tests +namespace Proffer.Storage.Azure.Blobs.Tests { using System; using System.IO; using System.Text; using System.Threading.Tasks; - using Microsoft.Extensions.DependencyInjection; using Proffer.Storage.Exceptions; using Storage; using Xunit; @@ -13,12 +12,12 @@ namespace Proffer.Storage.Azure.Tests [IntegrationTest] [Feature(nameof(Storage))] [Feature(nameof(Azure))] - [Collection(nameof(AzureCollection))] + [Collection(nameof(AzureBlobsCollection))] public class SaveTests : Abstract.ConfiguredStoresTestsBase { - private readonly AzureFixture fixture; + private readonly AzureBlobsFixture fixture; - public SaveTests(AzureFixture fixture) + public SaveTests(AzureBlobsFixture fixture) { this.fixture = fixture; } diff --git a/tests/Proffer.Storage.Azure.Tests/Stores/DefaultContent/Delete/ToDelete.txt b/tests/Proffer.Storage.Azure.Blobs.Tests/Stores/DefaultContent/Delete/ToDelete.txt similarity index 100% rename from tests/Proffer.Storage.Azure.Tests/Stores/DefaultContent/Delete/ToDelete.txt rename to tests/Proffer.Storage.Azure.Blobs.Tests/Stores/DefaultContent/Delete/ToDelete.txt diff --git a/tests/Proffer.Storage.Azure.Tests/Stores/DefaultContent/Delete/ToDelete2.txt b/tests/Proffer.Storage.Azure.Blobs.Tests/Stores/DefaultContent/Delete/ToDelete2.txt similarity index 100% rename from tests/Proffer.Storage.Azure.Tests/Stores/DefaultContent/Delete/ToDelete2.txt rename to tests/Proffer.Storage.Azure.Blobs.Tests/Stores/DefaultContent/Delete/ToDelete2.txt diff --git a/tests/Proffer.Storage.Azure.Tests/Stores/DefaultContent/Delete/ToSurvive.txt b/tests/Proffer.Storage.Azure.Blobs.Tests/Stores/DefaultContent/Delete/ToSurvive.txt similarity index 100% rename from tests/Proffer.Storage.Azure.Tests/Stores/DefaultContent/Delete/ToSurvive.txt rename to tests/Proffer.Storage.Azure.Blobs.Tests/Stores/DefaultContent/Delete/ToSurvive.txt diff --git a/tests/Proffer.Storage.Azure.Tests/Stores/DefaultContent/Delete/ToSurvive2.txt b/tests/Proffer.Storage.Azure.Blobs.Tests/Stores/DefaultContent/Delete/ToSurvive2.txt similarity index 100% rename from tests/Proffer.Storage.Azure.Tests/Stores/DefaultContent/Delete/ToSurvive2.txt rename to tests/Proffer.Storage.Azure.Blobs.Tests/Stores/DefaultContent/Delete/ToSurvive2.txt diff --git a/tests/Proffer.Storage.Azure.Tests/Stores/DefaultContent/Globbing/template-header.hbs b/tests/Proffer.Storage.Azure.Blobs.Tests/Stores/DefaultContent/Globbing/template-header.hbs similarity index 100% rename from tests/Proffer.Storage.Azure.Tests/Stores/DefaultContent/Globbing/template-header.hbs rename to tests/Proffer.Storage.Azure.Blobs.Tests/Stores/DefaultContent/Globbing/template-header.hbs diff --git a/tests/Proffer.Storage.Azure.Tests/Stores/DefaultContent/Globbing/template-header.mustache b/tests/Proffer.Storage.Azure.Blobs.Tests/Stores/DefaultContent/Globbing/template-header.mustache similarity index 100% rename from tests/Proffer.Storage.Azure.Tests/Stores/DefaultContent/Globbing/template-header.mustache rename to tests/Proffer.Storage.Azure.Blobs.Tests/Stores/DefaultContent/Globbing/template-header.mustache diff --git a/tests/Proffer.Storage.Azure.Tests/Stores/DefaultContent/Globbing/template.hbs b/tests/Proffer.Storage.Azure.Blobs.Tests/Stores/DefaultContent/Globbing/template.hbs similarity index 100% rename from tests/Proffer.Storage.Azure.Tests/Stores/DefaultContent/Globbing/template.hbs rename to tests/Proffer.Storage.Azure.Blobs.Tests/Stores/DefaultContent/Globbing/template.hbs diff --git a/tests/Proffer.Storage.Azure.Tests/Stores/DefaultContent/Globbing/template.mustache b/tests/Proffer.Storage.Azure.Blobs.Tests/Stores/DefaultContent/Globbing/template.mustache similarity index 100% rename from tests/Proffer.Storage.Azure.Tests/Stores/DefaultContent/Globbing/template.mustache rename to tests/Proffer.Storage.Azure.Blobs.Tests/Stores/DefaultContent/Globbing/template.mustache diff --git a/tests/Proffer.Storage.Azure.Tests/Stores/DefaultContent/Metadata/TextFile.txt b/tests/Proffer.Storage.Azure.Blobs.Tests/Stores/DefaultContent/Metadata/TextFile.txt similarity index 100% rename from tests/Proffer.Storage.Azure.Tests/Stores/DefaultContent/Metadata/TextFile.txt rename to tests/Proffer.Storage.Azure.Blobs.Tests/Stores/DefaultContent/Metadata/TextFile.txt diff --git a/tests/Proffer.Storage.Azure.Tests/Stores/DefaultContent/SubDirectory/TextFile2.txt b/tests/Proffer.Storage.Azure.Blobs.Tests/Stores/DefaultContent/SubDirectory/TextFile2.txt similarity index 100% rename from tests/Proffer.Storage.Azure.Tests/Stores/DefaultContent/SubDirectory/TextFile2.txt rename to tests/Proffer.Storage.Azure.Blobs.Tests/Stores/DefaultContent/SubDirectory/TextFile2.txt diff --git a/tests/Proffer.Storage.Azure.Tests/Stores/DefaultContent/TextFile.txt b/tests/Proffer.Storage.Azure.Blobs.Tests/Stores/DefaultContent/TextFile.txt similarity index 100% rename from tests/Proffer.Storage.Azure.Tests/Stores/DefaultContent/TextFile.txt rename to tests/Proffer.Storage.Azure.Blobs.Tests/Stores/DefaultContent/TextFile.txt diff --git a/tests/Proffer.Storage.Azure.Tests/Stores/DefaultContent/Update/TextFile.txt b/tests/Proffer.Storage.Azure.Blobs.Tests/Stores/DefaultContent/Update/TextFile.txt similarity index 100% rename from tests/Proffer.Storage.Azure.Tests/Stores/DefaultContent/Update/TextFile.txt rename to tests/Proffer.Storage.Azure.Blobs.Tests/Stores/DefaultContent/Update/TextFile.txt diff --git a/tests/Proffer.Storage.Azure.Tests/Stores/DefaultContent/template.hbs b/tests/Proffer.Storage.Azure.Blobs.Tests/Stores/DefaultContent/template.hbs similarity index 100% rename from tests/Proffer.Storage.Azure.Tests/Stores/DefaultContent/template.hbs rename to tests/Proffer.Storage.Azure.Blobs.Tests/Stores/DefaultContent/template.hbs diff --git a/tests/Proffer.Storage.Azure.Blobs.Tests/Stubs/AzureBlobsStoreOptionsStub.cs b/tests/Proffer.Storage.Azure.Blobs.Tests/Stubs/AzureBlobsStoreOptionsStub.cs new file mode 100644 index 0000000..71be68f --- /dev/null +++ b/tests/Proffer.Storage.Azure.Blobs.Tests/Stubs/AzureBlobsStoreOptionsStub.cs @@ -0,0 +1,16 @@ +namespace Proffer.Storage.Azure.Blobs.Tests.Stubs +{ + using System; + using Proffer.Storage.Azure.Blobs.Configuration; + using Storage.Configuration; + + public class AzureBlobsStoreOptionsStub : AzureBlobsStoreOptions + { + public AzureBlobsStoreOptionsStub() + { + this.Name = "GenericStore"; + this.ProviderType = "Azure"; + this.AccessLevel = ( DateTime.UtcNow.Day % 2 == 0 ) ? AccessLevel.Public : AccessLevel.Private; + } + } +} diff --git a/tests/Proffer.Storage.Azure.Tests/appsettings.json b/tests/Proffer.Storage.Azure.Blobs.Tests/appsettings.json similarity index 100% rename from tests/Proffer.Storage.Azure.Tests/appsettings.json rename to tests/Proffer.Storage.Azure.Blobs.Tests/appsettings.json diff --git a/tests/Proffer.Storage.Azure.Tests/AzureCollection.cs b/tests/Proffer.Storage.Azure.Tests/AzureCollection.cs deleted file mode 100644 index 1745650..0000000 --- a/tests/Proffer.Storage.Azure.Tests/AzureCollection.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Proffer.Storage.Azure.Tests -{ - using Xunit; - - [CollectionDefinition(nameof(AzureCollection))] - public class AzureCollection : ICollectionFixture { } -} diff --git a/tests/Proffer.Storage.Azure.Tests/Stubs/AzureStoreOptionsStub.cs b/tests/Proffer.Storage.Azure.Tests/Stubs/AzureStoreOptionsStub.cs deleted file mode 100644 index 95ea677..0000000 --- a/tests/Proffer.Storage.Azure.Tests/Stubs/AzureStoreOptionsStub.cs +++ /dev/null @@ -1,16 +0,0 @@ -namespace Proffer.Storage.Azure.Tests.Stubs -{ - using Storage.Configuration; - using Proffer.Storage.Azure.Configuration; - using System; - - public class AzureStoreOptionsStub : AzureStoreOptions - { - public AzureStoreOptionsStub() - { - this.Name = "GenericStore"; - this.ProviderType = "Azure"; - this.AccessLevel = (DateTime.UtcNow.Day % 2 == 0) ? AccessLevel.Public : AccessLevel.Private; - } - } -} diff --git a/tests/Proffer.Storage.FileSystem.Properties.Json.Tests/ReadTests.cs b/tests/Proffer.Storage.FileSystem.Properties.Json.Tests/ReadTests.cs index 3c04a83..030751b 100644 --- a/tests/Proffer.Storage.FileSystem.Properties.Json.Tests/ReadTests.cs +++ b/tests/Proffer.Storage.FileSystem.Properties.Json.Tests/ReadTests.cs @@ -1,6 +1,5 @@ namespace Proffer.Storage.FileSystem.Properties.Json.Tests { - using System; using System.Threading.Tasks; using Storage; using Xunit; diff --git a/tests/Proffer.Storage.FileSystem.Properties.Json.Tests/SaveTests.cs b/tests/Proffer.Storage.FileSystem.Properties.Json.Tests/SaveTests.cs index 3d7da08..6ab8067 100644 --- a/tests/Proffer.Storage.FileSystem.Properties.Json.Tests/SaveTests.cs +++ b/tests/Proffer.Storage.FileSystem.Properties.Json.Tests/SaveTests.cs @@ -10,7 +10,7 @@ namespace Proffer.Storage.FileSystem.Properties.Json.Tests [UnitTest] [Feature(nameof(Storage))] [Feature(nameof(FileSystem))] - [Feature(nameof(IExtendedPropertiesProvider))] + [Feature(nameof(IExtendedPropertiesProvider))] [Collection(nameof(FileSystemPropertiesJsonCollection))] public class SaveTests : Abstract.ConfiguredStoresTestsBase { diff --git a/tests/Proffer.Storage.FileSystem.Tests/FileSystemStorageServiceCollectionExtensionsTests.cs b/tests/Proffer.Storage.FileSystem.Tests/FileSystemStorageServiceCollectionExtensionsTests.cs index 1f9da05..081c122 100644 --- a/tests/Proffer.Storage.FileSystem.Tests/FileSystemStorageServiceCollectionExtensionsTests.cs +++ b/tests/Proffer.Storage.FileSystem.Tests/FileSystemStorageServiceCollectionExtensionsTests.cs @@ -60,7 +60,7 @@ public async Task Should_Throw_When_SavingProperties_With_DefaultExtendedPropert { $"Storage:Stores:{storeName}:ProviderType", "FileSystem" } }); - IOptions < FileSystemParsedOptions> options = fixture.Services.GetService>(); + IOptions options = fixture.Services.GetService>(); IStorageFactory storageFactory = fixture.Services.GetRequiredService(); IStore store = storageFactory.GetStore(storeName); diff --git a/tests/Proffer.Storage.Tests/StorageFactoryTests.cs b/tests/Proffer.Storage.Tests/StorageFactoryTests.cs index 69a9f3f..f236b2f 100644 --- a/tests/Proffer.Storage.Tests/StorageFactoryTests.cs +++ b/tests/Proffer.Storage.Tests/StorageFactoryTests.cs @@ -187,7 +187,7 @@ public void Should_ReturnNull_When_TryingToGetStore_With_UnknownProviderName() }); IStorageFactory storageFactory = fixture.Services.GetService(); - + bool storeFound = storageFactory.TryGetStore(storeName, out IStore store); Assert.False(storeFound); diff --git a/tests/Proffer.Storage.Tests/Stubs/Configuration/StubProviderInstanceOptions.cs b/tests/Proffer.Storage.Tests/Stubs/Configuration/StubProviderInstanceOptions.cs index 54179dd..e7cbfe2 100644 --- a/tests/Proffer.Storage.Tests/Stubs/Configuration/StubProviderInstanceOptions.cs +++ b/tests/Proffer.Storage.Tests/Stubs/Configuration/StubProviderInstanceOptions.cs @@ -3,6 +3,6 @@ namespace Proffer.Storage.Tests.Stubs.Configuration using Proffer.Storage.Configuration; public class StubProviderInstanceOptions : ProviderInstanceOptions - { + { } } From 1e838ce8bd6e6a57d98361aebc244c7bf3a08701 Mon Sep 17 00:00:00 2001 From: Adrien Siffermann Date: Fri, 7 May 2021 01:29:07 +0200 Subject: [PATCH 2/2] Common abstractions libraries Proffer and Proffer.Azure #92 #82 --- Proffer.sln | 68 ++++++++++++++----- .../Configuration/IAzureStorageOptions.cs | 18 +++++ src/Proffer.Azure/Proffer.Azure.csproj | 23 +++++++ .../AzureBlobsStorageProvider.cs | 2 +- ...BlobsStorageServiceCollectionExtensions.cs | 2 +- .../Configuration/AzureBlobsParsedOptions.cs | 8 +-- ...ptions.cs => AzureBlobsProviderOptions.cs} | 9 +-- .../Configuration/AzureBlobsStoreOptions.cs | 4 +- .../Proffer.Storage.Azure.Blobs.csproj | 1 + .../Configuration/FileSystemParsedOptions.cs | 8 +-- .../FileSystemProviderInstanceOptions.cs | 16 ----- .../FileSystemProviderOptions.cs | 16 +++++ .../Configuration/FileSystemStoreOptions.cs | 1 + .../FileSystemStorageProvider.cs | 2 +- ...ystemStorageServiceCollectionExtensions.cs | 2 +- .../Configuration/ConfigurationExtensions.cs | 23 ++++--- .../Configuration/IParsedOptions.cs | 19 +++--- .../Configuration/IStoreOptions.cs | 1 + .../Configuration/StorageOptions.cs | 15 ++-- .../Configuration/StoreOptions.cs | 1 + .../Exceptions/BadStoreConfiguration.cs | 5 +- .../Internal/ConfigureProviderOptions.cs | 19 +++--- .../Internal/StorageFactory.cs | 3 +- .../Internal/StorageProviderBase.cs | 3 +- src/Proffer.Storage/Proffer.Storage.csproj | 6 +- .../Configuration/INamedElementOptions.cs | 2 +- .../Configuration/IOptionError.cs | 2 +- .../Configuration/IProviderOptions.cs} | 6 +- .../Configuration/OptionError.cs | 2 +- .../Configuration/ProviderOptions.cs} | 8 +-- src/Proffer/Proffer.csproj | 19 ++++++ .../AzureBlobsFixture.cs | 2 +- .../FileSystemFixture.cs | 2 +- .../Stubs/FileSystemStoreOptionsStub.cs | 1 + .../StorageConfigurationTests.cs | 1 + .../Stubs/Configuration/StubParsedOptions.cs | 8 +-- .../StubProviderInstanceOptions.cs | 4 +- .../Stubs/StubStorageProvider.cs | 2 +- .../StubStorageServiceCollectionExtensions.cs | 2 +- 39 files changed, 224 insertions(+), 112 deletions(-) create mode 100644 src/Proffer.Azure/Configuration/IAzureStorageOptions.cs create mode 100644 src/Proffer.Azure/Proffer.Azure.csproj rename src/Proffer.Storage.Azure.Blobs/Configuration/{AzureBlobsProviderInstanceOptions.cs => AzureBlobsProviderOptions.cs} (62%) delete mode 100644 src/Proffer.Storage.FileSystem/Configuration/FileSystemProviderInstanceOptions.cs create mode 100644 src/Proffer.Storage.FileSystem/Configuration/FileSystemProviderOptions.cs rename src/{Proffer.Storage => Proffer}/Configuration/INamedElementOptions.cs (87%) rename src/{Proffer.Storage => Proffer}/Configuration/IOptionError.cs (90%) rename src/{Proffer.Storage/Configuration/IProviderInstanceOptions.cs => Proffer/Configuration/IProviderOptions.cs} (53%) rename src/{Proffer.Storage => Proffer}/Configuration/OptionError.cs (92%) rename src/{Proffer.Storage/Configuration/ProviderInstanceOptions.cs => Proffer/Configuration/ProviderOptions.cs} (55%) create mode 100644 src/Proffer/Proffer.csproj diff --git a/Proffer.sln b/Proffer.sln index f514f7d..8c6d755 100644 --- a/Proffer.sln +++ b/Proffer.sln @@ -69,6 +69,22 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Proffer.Storage.Azure.Blobs EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Proffer.Storage.Azure.Blobs.Tests", "tests\Proffer.Storage.Azure.Blobs.Tests\Proffer.Storage.Azure.Blobs.Tests.csproj", "{FE0568DD-0D79-4A87-B67D-751E8880F909}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Proffer.Azure", "src\Proffer.Azure\Proffer.Azure.csproj", "{25BE0184-A4E6-4373-9096-A9ACE46C6553}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Proffer", "src\Proffer\Proffer.csproj", "{61E7D303-3E52-43CF-B873-DD210A701E0C}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Email", "Email", "{BF1523C2-6954-4994-974E-E77F3ACE8398}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Storage", "Storage", "{278FD0BB-B382-455E-806F-32680299995D}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Templating", "Templating", "{93D47517-5E43-4E32-B64D-561D5BED4CE7}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Email", "Email", "{9DF1EED6-5002-428F-8834-77D201C679DD}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Storage", "Storage", "{CF4CBCB2-36F4-4D49-AC79-062FB7DDF878}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Templating", "Templating", "{6B4C6C7C-189A-42B4-8860-90652BDCC6B1}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -151,31 +167,47 @@ Global {FE0568DD-0D79-4A87-B67D-751E8880F909}.Debug|Any CPU.Build.0 = Debug|Any CPU {FE0568DD-0D79-4A87-B67D-751E8880F909}.Release|Any CPU.ActiveCfg = Release|Any CPU {FE0568DD-0D79-4A87-B67D-751E8880F909}.Release|Any CPU.Build.0 = Release|Any CPU + {25BE0184-A4E6-4373-9096-A9ACE46C6553}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {25BE0184-A4E6-4373-9096-A9ACE46C6553}.Debug|Any CPU.Build.0 = Debug|Any CPU + {25BE0184-A4E6-4373-9096-A9ACE46C6553}.Release|Any CPU.ActiveCfg = Release|Any CPU + {25BE0184-A4E6-4373-9096-A9ACE46C6553}.Release|Any CPU.Build.0 = Release|Any CPU + {61E7D303-3E52-43CF-B873-DD210A701E0C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {61E7D303-3E52-43CF-B873-DD210A701E0C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {61E7D303-3E52-43CF-B873-DD210A701E0C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {61E7D303-3E52-43CF-B873-DD210A701E0C}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection GlobalSection(NestedProjects) = preSolution {4E4394F6-91C7-43E2-BEDA-B7F8EBBA2C68} = {A08DBB7E-DDD4-49BB-9A49-5E3FB88EE878} - {0CA36021-3FA3-4688-8D61-A2B8A0FB168C} = {8B67DB72-5CC8-441F-9EFF-8F41BB637DA8} - {F53D7921-7828-4AF6-BE1E-DB81E80A65CC} = {8B67DB72-5CC8-441F-9EFF-8F41BB637DA8} - {E72BC0D9-6BD2-4D8D-8A59-ABB2815B1E85} = {8B67DB72-5CC8-441F-9EFF-8F41BB637DA8} - {BB8C05EF-BC14-4C92-9B07-2A616BA0FF45} = {8B67DB72-5CC8-441F-9EFF-8F41BB637DA8} - {A4D06911-E1A1-4339-A0F0-0F851F764EB4} = {8B67DB72-5CC8-441F-9EFF-8F41BB637DA8} - {EC165D4F-A105-482F-B1B5-9BF187410C62} = {8B67DB72-5CC8-441F-9EFF-8F41BB637DA8} - {E4F3443D-5922-4E44-91A2-3645B2E18949} = {8B67DB72-5CC8-441F-9EFF-8F41BB637DA8} - {FC2F0665-F55E-4557-90F8-DC66AA2C8658} = {8B67DB72-5CC8-441F-9EFF-8F41BB637DA8} - {D930DB6F-D3EF-4274-AC56-48268B68F6C2} = {8B67DB72-5CC8-441F-9EFF-8F41BB637DA8} - {71EB6650-2C03-4DA2-89FA-C4443CB0FB2A} = {8B67DB72-5CC8-441F-9EFF-8F41BB637DA8} - {60BA8317-9CDB-4002-9E43-88EB8BBB3280} = {8B67DB72-5CC8-441F-9EFF-8F41BB637DA8} + {0CA36021-3FA3-4688-8D61-A2B8A0FB168C} = {278FD0BB-B382-455E-806F-32680299995D} + {F53D7921-7828-4AF6-BE1E-DB81E80A65CC} = {278FD0BB-B382-455E-806F-32680299995D} + {E72BC0D9-6BD2-4D8D-8A59-ABB2815B1E85} = {278FD0BB-B382-455E-806F-32680299995D} + {BB8C05EF-BC14-4C92-9B07-2A616BA0FF45} = {278FD0BB-B382-455E-806F-32680299995D} + {A4D06911-E1A1-4339-A0F0-0F851F764EB4} = {93D47517-5E43-4E32-B64D-561D5BED4CE7} + {EC165D4F-A105-482F-B1B5-9BF187410C62} = {93D47517-5E43-4E32-B64D-561D5BED4CE7} + {E4F3443D-5922-4E44-91A2-3645B2E18949} = {93D47517-5E43-4E32-B64D-561D5BED4CE7} + {FC2F0665-F55E-4557-90F8-DC66AA2C8658} = {BF1523C2-6954-4994-974E-E77F3ACE8398} + {D930DB6F-D3EF-4274-AC56-48268B68F6C2} = {BF1523C2-6954-4994-974E-E77F3ACE8398} + {71EB6650-2C03-4DA2-89FA-C4443CB0FB2A} = {BF1523C2-6954-4994-974E-E77F3ACE8398} + {60BA8317-9CDB-4002-9E43-88EB8BBB3280} = {BF1523C2-6954-4994-974E-E77F3ACE8398} {815899B8-C129-469A-B169-2A59E65181F1} = {EB0DAEC2-2EEE-4833-8180-353882615CEC} - {A1BABC33-523C-419B-8407-67A3BCE53737} = {EB0DAEC2-2EEE-4833-8180-353882615CEC} - {1BBECE5A-7008-4D23-9DC6-FEC42AB57D85} = {EB0DAEC2-2EEE-4833-8180-353882615CEC} - {62473356-141D-438C-8D51-D34191F08A26} = {EB0DAEC2-2EEE-4833-8180-353882615CEC} - {1C21F39F-1045-4890-820E-F4328A2BAF86} = {EB0DAEC2-2EEE-4833-8180-353882615CEC} - {FDA33857-554F-4616-A674-06417AD6A0AF} = {EB0DAEC2-2EEE-4833-8180-353882615CEC} - {E0015649-ADB8-4D25-A14E-B2D5D3AD633F} = {8B67DB72-5CC8-441F-9EFF-8F41BB637DA8} - {FE0568DD-0D79-4A87-B67D-751E8880F909} = {EB0DAEC2-2EEE-4833-8180-353882615CEC} + {A1BABC33-523C-419B-8407-67A3BCE53737} = {9DF1EED6-5002-428F-8834-77D201C679DD} + {1BBECE5A-7008-4D23-9DC6-FEC42AB57D85} = {CF4CBCB2-36F4-4D49-AC79-062FB7DDF878} + {62473356-141D-438C-8D51-D34191F08A26} = {CF4CBCB2-36F4-4D49-AC79-062FB7DDF878} + {1C21F39F-1045-4890-820E-F4328A2BAF86} = {CF4CBCB2-36F4-4D49-AC79-062FB7DDF878} + {FDA33857-554F-4616-A674-06417AD6A0AF} = {CF4CBCB2-36F4-4D49-AC79-062FB7DDF878} + {E0015649-ADB8-4D25-A14E-B2D5D3AD633F} = {278FD0BB-B382-455E-806F-32680299995D} + {FE0568DD-0D79-4A87-B67D-751E8880F909} = {CF4CBCB2-36F4-4D49-AC79-062FB7DDF878} + {25BE0184-A4E6-4373-9096-A9ACE46C6553} = {8B67DB72-5CC8-441F-9EFF-8F41BB637DA8} + {61E7D303-3E52-43CF-B873-DD210A701E0C} = {8B67DB72-5CC8-441F-9EFF-8F41BB637DA8} + {BF1523C2-6954-4994-974E-E77F3ACE8398} = {8B67DB72-5CC8-441F-9EFF-8F41BB637DA8} + {278FD0BB-B382-455E-806F-32680299995D} = {8B67DB72-5CC8-441F-9EFF-8F41BB637DA8} + {93D47517-5E43-4E32-B64D-561D5BED4CE7} = {8B67DB72-5CC8-441F-9EFF-8F41BB637DA8} + {9DF1EED6-5002-428F-8834-77D201C679DD} = {EB0DAEC2-2EEE-4833-8180-353882615CEC} + {CF4CBCB2-36F4-4D49-AC79-062FB7DDF878} = {EB0DAEC2-2EEE-4833-8180-353882615CEC} + {6B4C6C7C-189A-42B4-8860-90652BDCC6B1} = {EB0DAEC2-2EEE-4833-8180-353882615CEC} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {6E14A063-006D-442F-BBA4-C9CF12D2438A} diff --git a/src/Proffer.Azure/Configuration/IAzureStorageOptions.cs b/src/Proffer.Azure/Configuration/IAzureStorageOptions.cs new file mode 100644 index 0000000..48ec2dd --- /dev/null +++ b/src/Proffer.Azure/Configuration/IAzureStorageOptions.cs @@ -0,0 +1,18 @@ +namespace Proffer.Azure.Configuration +{ + /// + /// Proffer options pointing to an Azure Storage account. + /// + public interface IAzureStorageOptions + { + /// + /// Gets or sets the connection string. + /// + public string ConnectionString { get; set; } + + /// + /// Gets or sets the name of the connection string to reference. + /// + public string ConnectionStringName { get; set; } + } +} diff --git a/src/Proffer.Azure/Proffer.Azure.csproj b/src/Proffer.Azure/Proffer.Azure.csproj new file mode 100644 index 0000000..904b29f --- /dev/null +++ b/src/Proffer.Azure/Proffer.Azure.csproj @@ -0,0 +1,23 @@ + + + + Proffer.Azure + Proffer.Azure + Proffer Azure common abstractions. + Proffer + Adrien Siffermann + https://github.com/asiffermann/proffer + + + + netstandard2 + latest + true + en-US + + + + + + + diff --git a/src/Proffer.Storage.Azure.Blobs/AzureBlobsStorageProvider.cs b/src/Proffer.Storage.Azure.Blobs/AzureBlobsStorageProvider.cs index 7e5c3da..c1916af 100644 --- a/src/Proffer.Storage.Azure.Blobs/AzureBlobsStorageProvider.cs +++ b/src/Proffer.Storage.Azure.Blobs/AzureBlobsStorageProvider.cs @@ -9,7 +9,7 @@ namespace Proffer.Storage.Azure.Blobs /// A provider to handle and build file stores pointing on an Azure Storage account. /// /// - public class AzureBlobsStorageProvider : StorageProviderBase + public class AzureBlobsStorageProvider : StorageProviderBase { /// /// The name. diff --git a/src/Proffer.Storage.Azure.Blobs/AzureBlobsStorageServiceCollectionExtensions.cs b/src/Proffer.Storage.Azure.Blobs/AzureBlobsStorageServiceCollectionExtensions.cs index 2d21881..cced130 100644 --- a/src/Proffer.Storage.Azure.Blobs/AzureBlobsStorageServiceCollectionExtensions.cs +++ b/src/Proffer.Storage.Azure.Blobs/AzureBlobsStorageServiceCollectionExtensions.cs @@ -20,7 +20,7 @@ public static class AzureBlobsStorageServiceCollectionExtensions public static IServiceCollection AddAzureStorage(this IServiceCollection services) { services - .AddSingleton, ConfigureProviderOptions>() + .AddSingleton, ConfigureProviderOptions>() .TryAddEnumerable(ServiceDescriptor.Transient()); return services; diff --git a/src/Proffer.Storage.Azure.Blobs/Configuration/AzureBlobsParsedOptions.cs b/src/Proffer.Storage.Azure.Blobs/Configuration/AzureBlobsParsedOptions.cs index 91bc8e0..6c47bc6 100644 --- a/src/Proffer.Storage.Azure.Blobs/Configuration/AzureBlobsParsedOptions.cs +++ b/src/Proffer.Storage.Azure.Blobs/Configuration/AzureBlobsParsedOptions.cs @@ -7,7 +7,7 @@ namespace Proffer.Storage.Azure.Blobs.Configuration /// Typed Azure Blobs options parsed from the dynamic configuration. /// /// - public class AzureBlobsParsedOptions : IParsedOptions + public class AzureBlobsParsedOptions : IParsedOptions { /// /// Gets the name. @@ -22,7 +22,7 @@ public class AzureBlobsParsedOptions : IParsedOptions /// Gets or sets the parsed provider instances options. /// - public IReadOnlyDictionary ParsedProviderInstances { get; set; } + public IReadOnlyDictionary ParsedProviders { get; set; } /// /// Gets or sets the parsed stores options. @@ -39,7 +39,7 @@ public class AzureBlobsParsedOptions : IParsedOptions /// The provider instance options. /// - public void BindProviderInstanceOptions(AzureBlobsProviderInstanceOptions providerInstanceOptions) + public void BindProviderOptions(AzureBlobsProviderOptions providerInstanceOptions) { if (!string.IsNullOrEmpty(providerInstanceOptions.ConnectionStringName) && string.IsNullOrEmpty(providerInstanceOptions.ConnectionString)) @@ -61,7 +61,7 @@ public void BindProviderInstanceOptions(AzureBlobsProviderInstanceOptions provid /// The store options. /// The provider instance options. /// - public void BindStoreOptions(AzureBlobsStoreOptions storeOptions, AzureBlobsProviderInstanceOptions providerInstanceOptions = null) + public void BindStoreOptions(AzureBlobsStoreOptions storeOptions, AzureBlobsProviderOptions providerInstanceOptions = null) { storeOptions.FolderName = storeOptions.FolderName.ToLowerInvariant(); diff --git a/src/Proffer.Storage.Azure.Blobs/Configuration/AzureBlobsProviderInstanceOptions.cs b/src/Proffer.Storage.Azure.Blobs/Configuration/AzureBlobsProviderOptions.cs similarity index 62% rename from src/Proffer.Storage.Azure.Blobs/Configuration/AzureBlobsProviderInstanceOptions.cs rename to src/Proffer.Storage.Azure.Blobs/Configuration/AzureBlobsProviderOptions.cs index 8b9f9a8..ee30613 100644 --- a/src/Proffer.Storage.Azure.Blobs/Configuration/AzureBlobsProviderInstanceOptions.cs +++ b/src/Proffer.Storage.Azure.Blobs/Configuration/AzureBlobsProviderOptions.cs @@ -1,12 +1,13 @@ namespace Proffer.Storage.Azure.Blobs.Configuration { - using Proffer.Storage.Configuration; + using Proffer.Azure.Configuration; + using Proffer.Configuration; /// - /// Options for an instance of . + /// Options for an . /// - /// - public class AzureBlobsProviderInstanceOptions : ProviderInstanceOptions + /// + public class AzureBlobsProviderOptions : ProviderOptions, IAzureStorageOptions { /// /// Gets or sets the connection string. diff --git a/src/Proffer.Storage.Azure.Blobs/Configuration/AzureBlobsStoreOptions.cs b/src/Proffer.Storage.Azure.Blobs/Configuration/AzureBlobsStoreOptions.cs index 2521fd7..f6c6e7d 100644 --- a/src/Proffer.Storage.Azure.Blobs/Configuration/AzureBlobsStoreOptions.cs +++ b/src/Proffer.Storage.Azure.Blobs/Configuration/AzureBlobsStoreOptions.cs @@ -2,13 +2,15 @@ namespace Proffer.Storage.Azure.Blobs.Configuration { using System.Collections.Generic; using System.Linq; + using Proffer.Azure.Configuration; + using Proffer.Configuration; using Proffer.Storage.Configuration; /// /// Options for an . /// /// - public class AzureBlobsStoreOptions : StoreOptions + public class AzureBlobsStoreOptions : StoreOptions, IAzureStorageOptions { /// /// Gets or sets the connection string. diff --git a/src/Proffer.Storage.Azure.Blobs/Proffer.Storage.Azure.Blobs.csproj b/src/Proffer.Storage.Azure.Blobs/Proffer.Storage.Azure.Blobs.csproj index 978f54c..8407924 100644 --- a/src/Proffer.Storage.Azure.Blobs/Proffer.Storage.Azure.Blobs.csproj +++ b/src/Proffer.Storage.Azure.Blobs/Proffer.Storage.Azure.Blobs.csproj @@ -17,6 +17,7 @@ + diff --git a/src/Proffer.Storage.FileSystem/Configuration/FileSystemParsedOptions.cs b/src/Proffer.Storage.FileSystem/Configuration/FileSystemParsedOptions.cs index 7c1d156..8f3a9bc 100644 --- a/src/Proffer.Storage.FileSystem/Configuration/FileSystemParsedOptions.cs +++ b/src/Proffer.Storage.FileSystem/Configuration/FileSystemParsedOptions.cs @@ -8,7 +8,7 @@ namespace Proffer.Storage.FileSystem.Configuration /// Typed File System options parsed from the dynamic configuration. /// /// - public class FileSystemParsedOptions : IParsedOptions + public class FileSystemParsedOptions : IParsedOptions { /// /// Gets the name. @@ -23,7 +23,7 @@ public class FileSystemParsedOptions : IParsedOptions /// Gets or sets the parsed provider instances options. /// - public IReadOnlyDictionary ParsedProviderInstances { get; set; } + public IReadOnlyDictionary ParsedProviders { get; set; } /// /// Gets or sets the parsed stores options. @@ -44,7 +44,7 @@ public class FileSystemParsedOptions : IParsedOptions /// The provider instance options. - public void BindProviderInstanceOptions(FileSystemProviderInstanceOptions providerInstanceOptions) + public void BindProviderOptions(FileSystemProviderOptions providerInstanceOptions) { if (string.IsNullOrEmpty(providerInstanceOptions.RootPath)) { @@ -64,7 +64,7 @@ public void BindProviderInstanceOptions(FileSystemProviderInstanceOptions provid /// /// The store options. /// The provider instance options. - public void BindStoreOptions(FileSystemStoreOptions storeOptions, FileSystemProviderInstanceOptions providerInstanceOptions = null) + public void BindStoreOptions(FileSystemStoreOptions storeOptions, FileSystemProviderOptions providerInstanceOptions = null) { if (string.IsNullOrEmpty(storeOptions.RootPath)) { diff --git a/src/Proffer.Storage.FileSystem/Configuration/FileSystemProviderInstanceOptions.cs b/src/Proffer.Storage.FileSystem/Configuration/FileSystemProviderInstanceOptions.cs deleted file mode 100644 index 22ea5df..0000000 --- a/src/Proffer.Storage.FileSystem/Configuration/FileSystemProviderInstanceOptions.cs +++ /dev/null @@ -1,16 +0,0 @@ -namespace Proffer.Storage.FileSystem.Configuration -{ - using Proffer.Storage.Configuration; - - /// - /// Options for an instance of . - /// - /// - public class FileSystemProviderInstanceOptions : ProviderInstanceOptions - { - /// - /// Gets or sets the root path. - /// - public string RootPath { get; set; } - } -} diff --git a/src/Proffer.Storage.FileSystem/Configuration/FileSystemProviderOptions.cs b/src/Proffer.Storage.FileSystem/Configuration/FileSystemProviderOptions.cs new file mode 100644 index 0000000..07a9317 --- /dev/null +++ b/src/Proffer.Storage.FileSystem/Configuration/FileSystemProviderOptions.cs @@ -0,0 +1,16 @@ +namespace Proffer.Storage.FileSystem.Configuration +{ + using Proffer.Configuration; + + /// + /// Options for a . + /// + /// + public class FileSystemProviderOptions : ProviderOptions + { + /// + /// Gets or sets the root path. + /// + public string RootPath { get; set; } + } +} diff --git a/src/Proffer.Storage.FileSystem/Configuration/FileSystemStoreOptions.cs b/src/Proffer.Storage.FileSystem/Configuration/FileSystemStoreOptions.cs index 6a4b75c..a484d7c 100644 --- a/src/Proffer.Storage.FileSystem/Configuration/FileSystemStoreOptions.cs +++ b/src/Proffer.Storage.FileSystem/Configuration/FileSystemStoreOptions.cs @@ -3,6 +3,7 @@ namespace Proffer.Storage.FileSystem.Configuration using System.Collections.Generic; using System.IO; using System.Linq; + using Proffer.Configuration; using Proffer.Storage.Configuration; /// diff --git a/src/Proffer.Storage.FileSystem/FileSystemStorageProvider.cs b/src/Proffer.Storage.FileSystem/FileSystemStorageProvider.cs index 0ab7385..8066d76 100644 --- a/src/Proffer.Storage.FileSystem/FileSystemStorageProvider.cs +++ b/src/Proffer.Storage.FileSystem/FileSystemStorageProvider.cs @@ -10,7 +10,7 @@ namespace Proffer.Storage.FileSystem /// A provider to handle and build file stores pointing on a File System directory. /// /// - public class FileSystemStorageProvider : StorageProviderBase + public class FileSystemStorageProvider : StorageProviderBase { /// /// The name. diff --git a/src/Proffer.Storage.FileSystem/FileSystemStorageServiceCollectionExtensions.cs b/src/Proffer.Storage.FileSystem/FileSystemStorageServiceCollectionExtensions.cs index 3291bd1..589e011 100644 --- a/src/Proffer.Storage.FileSystem/FileSystemStorageServiceCollectionExtensions.cs +++ b/src/Proffer.Storage.FileSystem/FileSystemStorageServiceCollectionExtensions.cs @@ -39,7 +39,7 @@ public static IServiceCollection AddFileSystemStorage(this IServiceCollection se private static IServiceCollection AddFileSystemStorageServices(this IServiceCollection services) { - services.AddSingleton, ConfigureProviderOptions>(); + services.AddSingleton, ConfigureProviderOptions>(); services.TryAddEnumerable(ServiceDescriptor.Transient()); services.TryAddTransient(); diff --git a/src/Proffer.Storage/Configuration/ConfigurationExtensions.cs b/src/Proffer.Storage/Configuration/ConfigurationExtensions.cs index c9ddeca..2f7fb5a 100644 --- a/src/Proffer.Storage/Configuration/ConfigurationExtensions.cs +++ b/src/Proffer.Storage/Configuration/ConfigurationExtensions.cs @@ -3,6 +3,7 @@ namespace Proffer.Storage.Configuration using System.Collections.Generic; using System.Linq; using Microsoft.Extensions.Configuration; + using Proffer.Configuration; /// /// Extensions methods to parse and bind options. @@ -41,7 +42,7 @@ public static IReadOnlyDictionary Parse(this IReadOn /// The typed store configuration. /// public static TStoreOptions GetStoreConfiguration(this IParsedOptions parsedOptions, string storeName, bool throwIfNotFound = true) - where TInstanceOptions : class, IProviderInstanceOptions + where TInstanceOptions : class, IProviderOptions where TStoreOptions : class, IStoreOptions where TScopedStoreOptions : class, TStoreOptions, IScopedStoreOptions { @@ -71,7 +72,7 @@ public static TStoreOptions GetStoreConfigurationThe typed scoped store configuration. /// public static TScopedStoreOptions GetScopedStoreConfiguration(this IParsedOptions parsedOptions, string storeName, bool throwIfNotFound = true) - where TInstanceOptions : class, IProviderInstanceOptions + where TInstanceOptions : class, IProviderOptions where TStoreOptions : class, IStoreOptions where TScopedStoreOptions : class, TStoreOptions, IScopedStoreOptions { @@ -93,19 +94,19 @@ public static TScopedStoreOptions GetScopedStoreConfiguration /// The type of the parsed options. - /// The type of the provider instance options. + /// The type of the provider instance options. /// The type of the store options. /// The type of the scoped store options. - /// The parsed provider instance options. + /// The provider options. /// The options. /// - public static void Compute(this TInstanceOptions parsedProviderInstance, TParsedOptions options) - where TParsedOptions : class, IParsedOptions - where TInstanceOptions : class, IProviderInstanceOptions, new() + public static void Compute(this TProviderOptions providerOptions, TParsedOptions options) + where TParsedOptions : class, IParsedOptions + where TProviderOptions : class, IProviderOptions, new() where TStoreOptions : class, IStoreOptions, new() where TScopedStoreOptions : class, TStoreOptions, IScopedStoreOptions { - options.BindProviderInstanceOptions(parsedProviderInstance); + options.BindProviderOptions(providerOptions); } /// @@ -120,7 +121,7 @@ public static void Compute public static void Compute(this TStoreOptions parsedStore, TParsedOptions options) where TParsedOptions : class, IParsedOptions - where TInstanceOptions : class, IProviderInstanceOptions, new() + where TInstanceOptions : class, IProviderOptions, new() where TStoreOptions : class, IStoreOptions, new() where TScopedStoreOptions : class, TStoreOptions, IScopedStoreOptions { @@ -132,7 +133,7 @@ public static void ComputeThe parsed store options. public static TStoreOptions ParseStoreOptions(this IStoreOptions storeOptions, TParsedOptions options) where TParsedOptions : class, IParsedOptions, new() - where TInstanceOptions : class, IProviderInstanceOptions, new() + where TInstanceOptions : class, IProviderOptions, new() where TStoreOptions : class, IStoreOptions, new() where TScopedStoreOptions : class, TStoreOptions, IScopedStoreOptions { diff --git a/src/Proffer.Storage/Configuration/IParsedOptions.cs b/src/Proffer.Storage/Configuration/IParsedOptions.cs index bf5fac2..65f5ba7 100644 --- a/src/Proffer.Storage/Configuration/IParsedOptions.cs +++ b/src/Proffer.Storage/Configuration/IParsedOptions.cs @@ -1,15 +1,16 @@ namespace Proffer.Storage.Configuration { using System.Collections.Generic; + using Proffer.Configuration; /// /// Typed options parsed from the dynamic configuration. /// - /// The type of the provider instance options. + /// The type of the provider instance options. /// The type of the store options. /// The type of the scoped store options. - public interface IParsedOptions - where TInstanceOptions : class, IProviderInstanceOptions + public interface IParsedOptions + where TProviderOptions : class, IProviderOptions where TStoreOptions : class, IStoreOptions where TScopedStoreOptions : class, TStoreOptions, IScopedStoreOptions { @@ -24,9 +25,9 @@ public interface IParsedOptions ConnectionStrings { get; set; } /// - /// Gets or sets the parsed provider instances options. + /// Gets or sets the parsed provider options. /// - IReadOnlyDictionary ParsedProviderInstances { get; set; } + IReadOnlyDictionary ParsedProviders { get; set; } /// /// Gets or sets the parsed stores options. @@ -39,10 +40,10 @@ public interface IParsedOptions ParsedScopedStores { get; set; } /// - /// Binds the provider instance options. + /// Binds the provider options. /// - /// The provider instance options. - void BindProviderInstanceOptions(TInstanceOptions providerInstanceOptions); + /// The provider options. + void BindProviderOptions(TProviderOptions providerOptions); /// /// Binds the store options. @@ -50,6 +51,6 @@ public interface IParsedOptionsThe store options. /// The provider instance options. /// - void BindStoreOptions(TStoreOptions storeOptions, TInstanceOptions providerInstanceOptions = null); + void BindStoreOptions(TStoreOptions storeOptions, TProviderOptions providerInstanceOptions = null); } } diff --git a/src/Proffer.Storage/Configuration/IStoreOptions.cs b/src/Proffer.Storage/Configuration/IStoreOptions.cs index e447811..1386b49 100644 --- a/src/Proffer.Storage/Configuration/IStoreOptions.cs +++ b/src/Proffer.Storage/Configuration/IStoreOptions.cs @@ -1,6 +1,7 @@ namespace Proffer.Storage.Configuration { using System.Collections.Generic; + using Proffer.Configuration; /// /// Options for an . diff --git a/src/Proffer.Storage/Configuration/StorageOptions.cs b/src/Proffer.Storage/Configuration/StorageOptions.cs index da84b33..fa861d6 100644 --- a/src/Proffer.Storage/Configuration/StorageOptions.cs +++ b/src/Proffer.Storage/Configuration/StorageOptions.cs @@ -3,19 +3,20 @@ namespace Proffer.Storage.Configuration using System; using System.Collections.Generic; using Microsoft.Extensions.Configuration; + using Proffer.Configuration; /// /// The Proffer.Storage options with providers and stores. /// /// - public class StorageOptions : IParsedOptions + public class StorageOptions : IParsedOptions { /// /// The default configuration section name. /// public const string DefaultConfigurationSectionName = "Storage"; - private readonly Lazy> parsedProviderInstances; + private readonly Lazy> parsedProviders; private readonly Lazy> parsedStores; private readonly Lazy> parsedScopedStores; @@ -24,8 +25,8 @@ public class StorageOptions : IParsedOptions public StorageOptions() { - this.parsedProviderInstances = new Lazy>( - () => this.Providers.Parse()); + this.parsedProviders = new Lazy>( + () => this.Providers.Parse()); this.parsedStores = new Lazy>( () => this.Stores.Parse()); this.parsedScopedStores = new Lazy>( @@ -60,7 +61,7 @@ public StorageOptions() /// /// Gets or sets the parsed provider instances options. /// - public IReadOnlyDictionary ParsedProviderInstances { get => this.parsedProviderInstances.Value; set { } } + public IReadOnlyDictionary ParsedProviders { get => this.parsedProviders.Value; set { } } /// /// Gets or sets the parsed stores options. @@ -76,13 +77,13 @@ public StorageOptions() /// Binds the provider instance options. /// /// The provider instance options. - public void BindProviderInstanceOptions(ProviderInstanceOptions providerInstanceOptions) { } + public void BindProviderOptions(ProviderOptions providerInstanceOptions) { } /// /// Binds the store options. /// /// The store options. /// The provider instance options. - public void BindStoreOptions(StoreOptions storeOptions, ProviderInstanceOptions providerInstanceOptions) { } + public void BindStoreOptions(StoreOptions storeOptions, ProviderOptions providerInstanceOptions) { } } } diff --git a/src/Proffer.Storage/Configuration/StoreOptions.cs b/src/Proffer.Storage/Configuration/StoreOptions.cs index 7f9086b..77bf0c8 100644 --- a/src/Proffer.Storage/Configuration/StoreOptions.cs +++ b/src/Proffer.Storage/Configuration/StoreOptions.cs @@ -2,6 +2,7 @@ namespace Proffer.Storage.Configuration { using System.Collections.Generic; using System.Linq; + using Proffer.Configuration; /// /// Generic options for an . diff --git a/src/Proffer.Storage/Exceptions/BadStoreConfiguration.cs b/src/Proffer.Storage/Exceptions/BadStoreConfiguration.cs index 18f64b2..e18fc00 100644 --- a/src/Proffer.Storage/Exceptions/BadStoreConfiguration.cs +++ b/src/Proffer.Storage/Exceptions/BadStoreConfiguration.cs @@ -3,6 +3,7 @@ namespace Proffer.Storage.Exceptions using System; using System.Collections.Generic; using System.Linq; + using Proffer.Configuration; /// /// Thrown when a store was not properly configured. @@ -25,7 +26,7 @@ public BadStoreConfiguration(string storeName, string details) /// /// The name of the store. /// The errors. - public BadStoreConfiguration(string storeName, IEnumerable errors) + public BadStoreConfiguration(string storeName, IEnumerable errors) : this(storeName, string.Join(" | ", errors.Select(e => e.ErrorMessage))) { this.Errors = errors; @@ -34,6 +35,6 @@ public BadStoreConfiguration(string storeName, IEnumerable /// Gets the validation errors. /// - public IEnumerable Errors { get; } + public IEnumerable Errors { get; } } } diff --git a/src/Proffer.Storage/Internal/ConfigureProviderOptions.cs b/src/Proffer.Storage/Internal/ConfigureProviderOptions.cs index 1c9d53b..fb57140 100644 --- a/src/Proffer.Storage/Internal/ConfigureProviderOptions.cs +++ b/src/Proffer.Storage/Internal/ConfigureProviderOptions.cs @@ -3,19 +3,20 @@ namespace Proffer.Storage.Internal using System.Collections.Generic; using System.Linq; using Microsoft.Extensions.Options; + using Proffer.Configuration; using Proffer.Storage.Configuration; /// /// Configures a provider from generic . /// /// The type of the parsed options. - /// The type of the provider instance options. + /// The type of the provider instance options. /// The type of the store options. /// The type of the scoped store options. /// - public class ConfigureProviderOptions : IConfigureOptions - where TParsedOptions : class, IParsedOptions - where TInstanceOptions : class, IProviderInstanceOptions, new() + public class ConfigureProviderOptions : IConfigureOptions + where TParsedOptions : class, IParsedOptions + where TProviderOptions : class, IProviderOptions, new() where TStoreOptions : class, IStoreOptions, new() where TScopedStoreOptions : class, TStoreOptions, IScopedStoreOptions, new() { @@ -45,19 +46,19 @@ public void Configure(TParsedOptions options) options.ConnectionStrings = this.storageOptions.ConnectionStrings; - options.ParsedProviderInstances = this.storageOptions.Providers.Parse() + options.ParsedProviders = this.storageOptions.Providers.Parse() .Where(kvp => kvp.Value.Type == options.Name) .ToDictionary(kvp => kvp.Key, kvp => kvp.Value); - foreach (KeyValuePair parsedProviderInstance in options.ParsedProviderInstances) + foreach (KeyValuePair providerOptions in options.ParsedProviders) { - parsedProviderInstance.Value.Compute(options); + providerOptions.Value.Compute(options); } IReadOnlyDictionary parsedStores = this.storageOptions.Stores.Parse(); foreach (KeyValuePair parsedStore in parsedStores) { - parsedStore.Value.Compute(options); + parsedStore.Value.Compute(options); } options.ParsedStores = parsedStores @@ -67,7 +68,7 @@ public void Configure(TParsedOptions options) IReadOnlyDictionary parsedScopedStores = this.storageOptions.ScopedStores.Parse(); foreach (KeyValuePair parsedScopedStore in parsedScopedStores) { - parsedScopedStore.Value.Compute(options); + parsedScopedStore.Value.Compute(options); } options.ParsedScopedStores = parsedScopedStores diff --git a/src/Proffer.Storage/Internal/StorageFactory.cs b/src/Proffer.Storage/Internal/StorageFactory.cs index 7af2960..0265b70 100644 --- a/src/Proffer.Storage/Internal/StorageFactory.cs +++ b/src/Proffer.Storage/Internal/StorageFactory.cs @@ -3,6 +3,7 @@ namespace Proffer.Storage.Internal using System.Collections.Generic; using System.Linq; using Microsoft.Extensions.Options; + using Proffer.Configuration; using Proffer.Storage.Configuration; /// @@ -144,7 +145,7 @@ private IStorageProvider GetProvider(IStoreOptions configuration, bool throwIfNo } else if (!string.IsNullOrEmpty(configuration.ProviderName)) { - this.options.ParsedProviderInstances.TryGetValue(configuration.ProviderName, out ProviderInstanceOptions providerInstanceOptions); + this.options.ParsedProviders.TryGetValue(configuration.ProviderName, out ProviderOptions providerInstanceOptions); if (providerInstanceOptions != null) { providerTypeName = providerInstanceOptions.Type; diff --git a/src/Proffer.Storage/Internal/StorageProviderBase.cs b/src/Proffer.Storage/Internal/StorageProviderBase.cs index 65a5fa3..2f19444 100644 --- a/src/Proffer.Storage/Internal/StorageProviderBase.cs +++ b/src/Proffer.Storage/Internal/StorageProviderBase.cs @@ -3,6 +3,7 @@ namespace Proffer.Storage.Internal using System; using Configuration; using Microsoft.Extensions.Options; + using Proffer.Configuration; /// /// A base provider to handle and build file stores pointing on a particular storage system location. @@ -14,7 +15,7 @@ namespace Proffer.Storage.Internal /// public abstract class StorageProviderBase : IStorageProvider where TParsedOptions : class, IParsedOptions, new() - where TInstanceOptions : class, IProviderInstanceOptions, new() + where TInstanceOptions : class, IProviderOptions, new() where TStoreOptions : class, IStoreOptions, new() where TScopedStoreOptions : class, TStoreOptions, IScopedStoreOptions { diff --git a/src/Proffer.Storage/Proffer.Storage.csproj b/src/Proffer.Storage/Proffer.Storage.csproj index a190ec3..638d8c5 100644 --- a/src/Proffer.Storage/Proffer.Storage.csproj +++ b/src/Proffer.Storage/Proffer.Storage.csproj @@ -1,4 +1,4 @@ - + Proffer.Storage @@ -16,6 +16,10 @@ en-US + + + + diff --git a/src/Proffer.Storage/Configuration/INamedElementOptions.cs b/src/Proffer/Configuration/INamedElementOptions.cs similarity index 87% rename from src/Proffer.Storage/Configuration/INamedElementOptions.cs rename to src/Proffer/Configuration/INamedElementOptions.cs index b7bb451..c0b15d0 100644 --- a/src/Proffer.Storage/Configuration/INamedElementOptions.cs +++ b/src/Proffer/Configuration/INamedElementOptions.cs @@ -1,4 +1,4 @@ -namespace Proffer.Storage.Configuration +namespace Proffer.Configuration { /// /// A named element from the options (provider or scope). diff --git a/src/Proffer.Storage/Configuration/IOptionError.cs b/src/Proffer/Configuration/IOptionError.cs similarity index 90% rename from src/Proffer.Storage/Configuration/IOptionError.cs rename to src/Proffer/Configuration/IOptionError.cs index db1b3ea..73b234b 100644 --- a/src/Proffer.Storage/Configuration/IOptionError.cs +++ b/src/Proffer/Configuration/IOptionError.cs @@ -1,4 +1,4 @@ -namespace Proffer.Storage.Configuration +namespace Proffer.Configuration { /// /// An error reported from the options validation. diff --git a/src/Proffer.Storage/Configuration/IProviderInstanceOptions.cs b/src/Proffer/Configuration/IProviderOptions.cs similarity index 53% rename from src/Proffer.Storage/Configuration/IProviderInstanceOptions.cs rename to src/Proffer/Configuration/IProviderOptions.cs index 3a62c0d..039fa9c 100644 --- a/src/Proffer.Storage/Configuration/IProviderInstanceOptions.cs +++ b/src/Proffer/Configuration/IProviderOptions.cs @@ -1,10 +1,10 @@ -namespace Proffer.Storage.Configuration +namespace Proffer.Configuration { /// - /// Options for an instance of . + /// Options of a provider. /// /// - public interface IProviderInstanceOptions : INamedElementOptions + public interface IProviderOptions : INamedElementOptions { /// /// Gets the type. diff --git a/src/Proffer.Storage/Configuration/OptionError.cs b/src/Proffer/Configuration/OptionError.cs similarity index 92% rename from src/Proffer.Storage/Configuration/OptionError.cs rename to src/Proffer/Configuration/OptionError.cs index ba13623..42fe5ab 100644 --- a/src/Proffer.Storage/Configuration/OptionError.cs +++ b/src/Proffer/Configuration/OptionError.cs @@ -1,4 +1,4 @@ -namespace Proffer.Storage.Configuration +namespace Proffer.Configuration { /// /// A generic error reported from the options validation. diff --git a/src/Proffer.Storage/Configuration/ProviderInstanceOptions.cs b/src/Proffer/Configuration/ProviderOptions.cs similarity index 55% rename from src/Proffer.Storage/Configuration/ProviderInstanceOptions.cs rename to src/Proffer/Configuration/ProviderOptions.cs index b23daa8..d92343c 100644 --- a/src/Proffer.Storage/Configuration/ProviderInstanceOptions.cs +++ b/src/Proffer/Configuration/ProviderOptions.cs @@ -1,10 +1,10 @@ -namespace Proffer.Storage.Configuration +namespace Proffer.Configuration { /// - /// Generic options for an instance of . + /// Standard options for a provider. /// - /// - public class ProviderInstanceOptions : IProviderInstanceOptions + /// + public class ProviderOptions : IProviderOptions { /// /// Gets or sets the name. diff --git a/src/Proffer/Proffer.csproj b/src/Proffer/Proffer.csproj new file mode 100644 index 0000000..d51f89e --- /dev/null +++ b/src/Proffer/Proffer.csproj @@ -0,0 +1,19 @@ + + + + Proffer + Proffer + .NET Core basic abstractions to configuration-driven providers. + Proffer + Adrien Siffermann + https://github.com/asiffermann/proffer + + + + netstandard2 + latest + true + en-US + + + diff --git a/tests/Proffer.Storage.Azure.Blobs.Tests/AzureBlobsFixture.cs b/tests/Proffer.Storage.Azure.Blobs.Tests/AzureBlobsFixture.cs index 30a7218..e201ac1 100644 --- a/tests/Proffer.Storage.Azure.Blobs.Tests/AzureBlobsFixture.cs +++ b/tests/Proffer.Storage.Azure.Blobs.Tests/AzureBlobsFixture.cs @@ -22,7 +22,7 @@ public AzureBlobsFixture() { this.ParsedOptions = this.Services.GetService>().Value; this.GenericStoreOptions = this.Services.GetService>().Value - .ParseStoreOptions(this.ParsedOptions); + .ParseStoreOptions(this.ParsedOptions); this.InitStores(); } diff --git a/tests/Proffer.Storage.FileSystem.Tests/FileSystemFixture.cs b/tests/Proffer.Storage.FileSystem.Tests/FileSystemFixture.cs index 16229fa..e54c83d 100644 --- a/tests/Proffer.Storage.FileSystem.Tests/FileSystemFixture.cs +++ b/tests/Proffer.Storage.FileSystem.Tests/FileSystemFixture.cs @@ -17,7 +17,7 @@ public FileSystemFixture() { this.ParsedOptions = this.Services.GetService>().Value; this.TestStoreOptions = this.Services.GetService>().Value - .ParseStoreOptions(this.ParsedOptions); + .ParseStoreOptions(this.ParsedOptions); this.ResetStores(); } diff --git a/tests/Proffer.Storage.FileSystem.Tests/Stubs/FileSystemStoreOptionsStub.cs b/tests/Proffer.Storage.FileSystem.Tests/Stubs/FileSystemStoreOptionsStub.cs index f8671c1..dc1fc40 100644 --- a/tests/Proffer.Storage.FileSystem.Tests/Stubs/FileSystemStoreOptionsStub.cs +++ b/tests/Proffer.Storage.FileSystem.Tests/Stubs/FileSystemStoreOptionsStub.cs @@ -2,6 +2,7 @@ namespace Proffer.Storage.FileSystem.Tests.Stubs { using System.Collections.Generic; using System.Linq; + using Proffer.Configuration; using Proffer.Storage.Configuration; public class FileSystemStoreOptionsStub : IStoreOptions diff --git a/tests/Proffer.Storage.Tests/StorageConfigurationTests.cs b/tests/Proffer.Storage.Tests/StorageConfigurationTests.cs index b6b6244..1794f23 100644 --- a/tests/Proffer.Storage.Tests/StorageConfigurationTests.cs +++ b/tests/Proffer.Storage.Tests/StorageConfigurationTests.cs @@ -4,6 +4,7 @@ namespace Proffer.Storage.Tests using System.Linq; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Options; + using Proffer.Configuration; using Proffer.Storage.Configuration; using Proffer.Storage.Exceptions; using Proffer.Storage.Tests.Stubs.Configuration; diff --git a/tests/Proffer.Storage.Tests/Stubs/Configuration/StubParsedOptions.cs b/tests/Proffer.Storage.Tests/Stubs/Configuration/StubParsedOptions.cs index 7be3815..1905ffc 100644 --- a/tests/Proffer.Storage.Tests/Stubs/Configuration/StubParsedOptions.cs +++ b/tests/Proffer.Storage.Tests/Stubs/Configuration/StubParsedOptions.cs @@ -3,20 +3,20 @@ namespace Proffer.Storage.Tests.Stubs.Configuration using System.Collections.Generic; using Proffer.Storage.Configuration; - public class StubParsedOptions : IParsedOptions + public class StubParsedOptions : IParsedOptions { public string Name => StubStorageProvider.ProviderName; public IReadOnlyDictionary ConnectionStrings { get; set; } - public IReadOnlyDictionary ParsedProviderInstances { get; set; } + public IReadOnlyDictionary ParsedProviders { get; set; } public IReadOnlyDictionary ParsedStores { get; set; } public IReadOnlyDictionary ParsedScopedStores { get; set; } - public void BindProviderInstanceOptions(StubProviderInstanceOptions providerInstanceOptions) { } + public void BindProviderOptions(StubProviderOptions providerInstanceOptions) { } - public void BindStoreOptions(StubStoreOptions storeOptions, StubProviderInstanceOptions providerInstanceOptions = null) { } + public void BindStoreOptions(StubStoreOptions storeOptions, StubProviderOptions providerInstanceOptions = null) { } } } diff --git a/tests/Proffer.Storage.Tests/Stubs/Configuration/StubProviderInstanceOptions.cs b/tests/Proffer.Storage.Tests/Stubs/Configuration/StubProviderInstanceOptions.cs index e7cbfe2..ebca38b 100644 --- a/tests/Proffer.Storage.Tests/Stubs/Configuration/StubProviderInstanceOptions.cs +++ b/tests/Proffer.Storage.Tests/Stubs/Configuration/StubProviderInstanceOptions.cs @@ -1,8 +1,8 @@ namespace Proffer.Storage.Tests.Stubs.Configuration { - using Proffer.Storage.Configuration; + using Proffer.Configuration; - public class StubProviderInstanceOptions : ProviderInstanceOptions + public class StubProviderOptions : ProviderOptions { } } diff --git a/tests/Proffer.Storage.Tests/Stubs/StubStorageProvider.cs b/tests/Proffer.Storage.Tests/Stubs/StubStorageProvider.cs index 193f7d3..4003381 100644 --- a/tests/Proffer.Storage.Tests/Stubs/StubStorageProvider.cs +++ b/tests/Proffer.Storage.Tests/Stubs/StubStorageProvider.cs @@ -5,7 +5,7 @@ namespace Proffer.Storage.Tests.Stubs using Proffer.Storage.Internal; using Proffer.Storage.Tests.Stubs.Configuration; - public class StubStorageProvider : StorageProviderBase + public class StubStorageProvider : StorageProviderBase { public const string ProviderName = "Stub"; diff --git a/tests/Proffer.Storage.Tests/Stubs/StubStorageServiceCollectionExtensions.cs b/tests/Proffer.Storage.Tests/Stubs/StubStorageServiceCollectionExtensions.cs index 6e5aa3d..00d108f 100644 --- a/tests/Proffer.Storage.Tests/Stubs/StubStorageServiceCollectionExtensions.cs +++ b/tests/Proffer.Storage.Tests/Stubs/StubStorageServiceCollectionExtensions.cs @@ -12,7 +12,7 @@ public static class StubStorageServiceCollectionExtensions public static IServiceCollection AddStubStorage(this IServiceCollection services) { services - .AddSingleton, ConfigureProviderOptions>() + .AddSingleton, ConfigureProviderOptions>() .TryAddEnumerable(ServiceDescriptor.Transient()); return services;