diff --git a/src/Orchard/Environment/Configuration/AppConfigurationAccessor.cs b/src/Orchard/Environment/Configuration/AppConfigurationAccessor.cs new file mode 100644 index 000000000..a03cfea45 --- /dev/null +++ b/src/Orchard/Environment/Configuration/AppConfigurationAccessor.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Configuration; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Orchard.Environment.Configuration { + public class AppConfigurationAccessor : IAppConfigurationAccessor { + public string GetConfiguration(string name) { + var appSettingsValue = ConfigurationManager.AppSettings[name]; + if (appSettingsValue != null) { + return appSettingsValue; + } + + var connectionStringSettings = ConfigurationManager.ConnectionStrings[name]; + if (connectionStringSettings != null) { + return connectionStringSettings.ConnectionString; + } + + return String.Empty; + } + } +} diff --git a/src/Orchard/Environment/Configuration/IAppConfigurationAccessor.cs b/src/Orchard/Environment/Configuration/IAppConfigurationAccessor.cs new file mode 100644 index 000000000..d32ef8e20 --- /dev/null +++ b/src/Orchard/Environment/Configuration/IAppConfigurationAccessor.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Orchard.Environment.Configuration { + /// + /// Exposes application configuration (can be e.g. AppSettings from Web.config or CloudConfiguration on Azure). + /// + public interface IAppConfigurationAccessor : IDependency { + /// + /// Gets an application configuration value with the given name (can be e.g. AppSettings from Web.config or CloudConfiguration on Azure). + /// + /// The name of the application configuration entry. + /// The string value of the application configuration entry. + string GetConfiguration(string name); + } +} diff --git a/src/Orchard/Orchard.Framework.csproj b/src/Orchard/Orchard.Framework.csproj index 6b7245378..e61e30e5b 100644 --- a/src/Orchard/Orchard.Framework.csproj +++ b/src/Orchard/Orchard.Framework.csproj @@ -225,6 +225,8 @@ + +