mirror of https://github.com/abpframework/abp.git
6 changed files with 99 additions and 1 deletions
@ -0,0 +1,12 @@ |
|||||
|
namespace Volo.Abp.BlobStoring |
||||
|
{ |
||||
|
public class AbpBlobStoringOptions |
||||
|
{ |
||||
|
public BlobContainerConfigurationDictionary Containers { get; set; } |
||||
|
|
||||
|
public AbpBlobStoringOptions() |
||||
|
{ |
||||
|
Containers = new BlobContainerConfigurationDictionary(); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,9 @@ |
|||||
|
using System.Collections.Generic; |
||||
|
|
||||
|
namespace Volo.Abp.BlobStoring |
||||
|
{ |
||||
|
public class BlobContainerConfiguration : Dictionary<string, object> |
||||
|
{ |
||||
|
|
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,22 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
|
||||
|
namespace Volo.Abp.BlobStoring |
||||
|
{ |
||||
|
public class BlobContainerConfigurationDictionary : Dictionary<string, BlobContainerConfiguration> |
||||
|
{ |
||||
|
public BlobContainerConfigurationDictionary Configure<TContainer>(Action<BlobContainerConfiguration> configureAction) |
||||
|
{ |
||||
|
return Configure( |
||||
|
BlobContainerNameAttribute.GetContainerName<TContainer>(), |
||||
|
configureAction |
||||
|
); |
||||
|
} |
||||
|
|
||||
|
public BlobContainerConfigurationDictionary Configure(string name, Action<BlobContainerConfiguration> configureAction) |
||||
|
{ |
||||
|
configureAction(this.GetOrAdd(name, () => new BlobContainerConfiguration())); |
||||
|
return this; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,29 @@ |
|||||
|
using System.Collections.Generic; |
||||
|
using Microsoft.Extensions.Options; |
||||
|
using Shouldly; |
||||
|
using Xunit; |
||||
|
|
||||
|
namespace Volo.Abp.BlobStoring |
||||
|
{ |
||||
|
public class AbpBlobStoringOptions_Tests : AbpBlobStoringTestBase |
||||
|
{ |
||||
|
private readonly AbpBlobStoringOptions _options; |
||||
|
|
||||
|
public AbpBlobStoringOptions_Tests() |
||||
|
{ |
||||
|
_options = GetRequiredService<IOptions<AbpBlobStoringOptions>>().Value; |
||||
|
} |
||||
|
|
||||
|
[Fact] |
||||
|
public void Should_Property_Set_And_Get_Options_For_Different_Containers() |
||||
|
{ |
||||
|
var testContainer1Config = _options.Containers |
||||
|
.GetOrDefault(BlobContainerNameAttribute.GetContainerName<TestContainer1>()); |
||||
|
testContainer1Config.ShouldContainKeyAndValue("TestConfig1", "TestValue1"); |
||||
|
|
||||
|
var testContainer2Config = _options.Containers |
||||
|
.GetOrDefault(BlobContainerNameAttribute.GetContainerName<TestContainer2>()); |
||||
|
testContainer2Config.ShouldContainKeyAndValue("TestConfig2", "TestValue2"); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,12 @@ |
|||||
|
namespace Volo.Abp.BlobStoring |
||||
|
{ |
||||
|
public class TestContainer1 |
||||
|
{ |
||||
|
|
||||
|
} |
||||
|
|
||||
|
public class TestContainer2 |
||||
|
{ |
||||
|
|
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue