Skip to content

Commit 25aaa54

Browse files
committed
Renaming media specific Composer and Component as their maybe other providers and changing app settings to be consistent with v1
1 parent 0a96737 commit 25aaa54

File tree

4 files changed

+41
-22
lines changed

4 files changed

+41
-22
lines changed

src/UmbracoFileSystemProviders.Azure/AzureFileSystemComponent.cs renamed to src/UmbracoFileSystemProviders.Azure/AzureMediaFileSystemComponent.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ namespace Our.Umbraco.FileSystemProviders.Azure
77
using global:: Umbraco.Core.Composing;
88
using global::Umbraco.Core.IO;
99

10-
public class AzureFileSystemComponent : IComponent
10+
public class AzureMediaFileSystemComponent : IComponent
1111
{
1212

1313
private readonly SupportingFileSystems supportingFileSystems;
1414
private readonly AzureBlobFileSystemConfig config;
1515

16-
public AzureFileSystemComponent(SupportingFileSystems supportingFileSystems, AzureBlobFileSystemConfig config)
16+
public AzureMediaFileSystemComponent(SupportingFileSystems supportingFileSystems, AzureBlobFileSystemConfig config)
1717
{
1818
this.supportingFileSystems = supportingFileSystems;
1919
this.config = config;

src/UmbracoFileSystemProviders.Azure/AzureFileSystemComposer.cs renamed to src/UmbracoFileSystemProviders.Azure/AzureMediaFileSystemComposer.cs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
namespace Our.Umbraco.FileSystemProviders.Azure
22
{
33
using System;
4-
using System.Configuration;
54
using global::Umbraco.Core;
65
using global::Umbraco.Core.Composing;
76
using global::Umbraco.Core.Exceptions;
87

98
[RuntimeLevel(MinLevel = RuntimeLevel.Run)]
10-
public class AzureFileSystemComposer : IComposer
9+
public class AzureMediaFileSystemComposer : IComposer
1110
{
11+
private const string ProviderAlias = "media";
1212
public void Compose(Composition composition)
1313
{
1414
// if no connectionString appSetting then Umbraco installer hasn't completed yet
15-
var connectionString = ConfigurationManager.AppSettings[Constants.Configuration.ConnectionStringKey];
15+
var connectionString = ConfigurationHelper.GetAppSetting(Constants.Configuration.ConnectionStringKey, ProviderAlias);
1616
if (connectionString != null)
1717
{
1818
//Configuration
@@ -25,40 +25,40 @@ public void Compose(Composition composition)
2525
composition.SetMediaFileSystem(_ => new AzureBlobFileSystem(config));
2626

2727
//Register component that deals with the VirtualPathProvider
28-
composition.Components().Append<AzureFileSystemComponent>();
28+
composition.Components().Append<AzureMediaFileSystemComponent>();
2929
}
3030
}
3131

3232
private AzureBlobFileSystemConfig CreateConfiguration()
3333
{
34-
var containerName = ConfigurationManager.AppSettings[Constants.Configuration.ContainerNameKey];
35-
var rootUrl = ConfigurationManager.AppSettings[Constants.Configuration.RootUrlKey];
36-
var connectionString = ConfigurationManager.AppSettings[Constants.Configuration.ConnectionStringKey];
37-
var maxDays = ConfigurationManager.AppSettings[Constants.Configuration.MaxDaysKey];
38-
var useDefaultRoute = ConfigurationManager.AppSettings[Constants.Configuration.UseDefaultRouteKey];
39-
var usePrivateContainer = ConfigurationManager.AppSettings[Constants.Configuration.UsePrivateContainer];
34+
var containerName = ConfigurationHelper.GetAppSetting(Constants.Configuration.ContainerNameKey, ProviderAlias);
35+
var rootUrl = ConfigurationHelper.GetAppSetting(Constants.Configuration.RootUrlKey, ProviderAlias);
36+
var connectionString = ConfigurationHelper.GetAppSetting(Constants.Configuration.ConnectionStringKey, ProviderAlias);
37+
var maxDays = ConfigurationHelper.GetAppSetting(Constants.Configuration.MaxDaysKey, ProviderAlias);
38+
var useDefaultRoute = ConfigurationHelper.GetAppSetting(Constants.Configuration.UseDefaultRouteKey, ProviderAlias);
39+
var usePrivateContainer = ConfigurationHelper.GetAppSetting(Constants.Configuration.UsePrivateContainer, ProviderAlias);
4040

4141
//Check we have all values set - otherwise make sure Umbraco does NOT boot so it can be configured correctly
4242
if (string.IsNullOrEmpty(containerName))
43-
throw new ArgumentNullOrEmptyException("containerName", $"The Azure File System is missing the value '{Constants.Configuration.ContainerNameKey}' from AppSettings");
43+
throw new ArgumentNullOrEmptyException("containerName", $"The Azure File System is missing the value '{Constants.Configuration.ContainerNameKey}:{ProviderAlias}' from AppSettings");
4444

4545
if (string.IsNullOrEmpty(rootUrl))
46-
throw new ArgumentNullOrEmptyException("rootUrl", $"The Azure File System is missing the value '{Constants.Configuration.RootUrlKey}' from AppSettings");
46+
throw new ArgumentNullOrEmptyException("rootUrl", $"The Azure File System is missing the value '{Constants.Configuration.RootUrlKey}:{ProviderAlias}' from AppSettings");
4747

4848
if (string.IsNullOrEmpty(connectionString))
49-
throw new ArgumentNullOrEmptyException("connectionString", $"The Azure File System is missing the value '{Constants.Configuration.ConnectionStringKey}' from AppSettings");
49+
throw new ArgumentNullOrEmptyException("connectionString", $"The Azure File System is missing the value '{Constants.Configuration.ConnectionStringKey}:{ProviderAlias}' from AppSettings");
5050

5151
if (string.IsNullOrEmpty(maxDays))
52-
throw new ArgumentNullOrEmptyException("maxDays", $"The Azure File System is missing the value '{Constants.Configuration.MaxDaysKey}' from AppSettings");
52+
throw new ArgumentNullOrEmptyException("maxDays", $"The Azure File System is missing the value '{Constants.Configuration.MaxDaysKey}:{ProviderAlias}' from AppSettings");
5353

5454
if (string.IsNullOrEmpty(useDefaultRoute))
55-
throw new ArgumentNullOrEmptyException("useDefaultRoute", $"The Azure File System is missing the value '{Constants.Configuration.UseDefaultRouteKey}' from AppSettings");
55+
throw new ArgumentNullOrEmptyException("useDefaultRoute", $"The Azure File System is missing the value '{Constants.Configuration.UseDefaultRouteKey}:{ProviderAlias}' from AppSettings");
5656

5757
if (string.IsNullOrEmpty(usePrivateContainer))
58-
throw new ArgumentNullOrEmptyException("usePrivateContainer", $"The Azure File System is missing the value '{Constants.Configuration.UsePrivateContainer}' from AppSettings");
58+
throw new ArgumentNullOrEmptyException("usePrivateContainer", $"The Azure File System is missing the value '{Constants.Configuration.UsePrivateContainer}:{ProviderAlias}' from AppSettings");
5959

60-
bool disableVirtualPathProvider = ConfigurationManager.AppSettings[Constants.Configuration.DisableVirtualPathProviderKey] != null
61-
&& ConfigurationManager.AppSettings[Constants.Configuration.DisableVirtualPathProviderKey]
60+
bool disableVirtualPathProvider = ConfigurationHelper.GetAppSetting(Constants.Configuration.DisableVirtualPathProviderKey, ProviderAlias) != null
61+
&& ConfigurationHelper.GetAppSetting(Constants.Configuration.DisableVirtualPathProviderKey, ProviderAlias)
6262
.Equals("true", StringComparison.InvariantCultureIgnoreCase);
6363

6464
return new AzureBlobFileSystemConfig
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
namespace Our.Umbraco.FileSystemProviders.Azure
2+
{
3+
using System.Configuration;
4+
5+
public class ConfigurationHelper
6+
{
7+
public static string GetAppSetting(string key, string providerAlias)
8+
{
9+
var settingValue = ConfigurationManager.AppSettings[key];
10+
if (settingValue != null)
11+
{
12+
return $"{settingValue}:{providerAlias}";
13+
}
14+
15+
return null;
16+
}
17+
}
18+
}

src/UmbracoFileSystemProviders.Azure/UmbracoFileSystemProviders.Azure.csproj

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -295,9 +295,10 @@
295295
<Compile Include="AzureBlobFileSystem.cs" />
296296
<Compile Include="AzureBlobFileSystemConfig.cs" />
297297
<Compile Include="AzureFileSystem.cs" />
298-
<Compile Include="AzureFileSystemComponent.cs" />
299-
<Compile Include="AzureFileSystemComposer.cs" />
298+
<Compile Include="AzureMediaFileSystemComponent.cs" />
299+
<Compile Include="AzureMediaFileSystemComposer.cs" />
300300
<Compile Include="Constants.cs" />
301+
<Compile Include="Helpers\ConfigurationHelper.cs" />
301302
<Compile Include="Helpers\IMimeTypeResolver.cs" />
302303
<Compile Include="Helpers\MimeTypeResolver.cs" />
303304
<Compile Include="Helpers\XmlHelper.cs" />

0 commit comments

Comments
 (0)