mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
Merge branch '1.x' of https://git01.codeplex.com/orchard into 1.x
This commit is contained in:
@@ -21,12 +21,13 @@
|
||||
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=5.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
|
||||
<pages pageBaseType="Orchard.Mvc.ViewEngines.Razor.WebViewPage">
|
||||
<namespaces>
|
||||
<add namespace="System.Collections.Generic"/>
|
||||
<add namespace="System.Linq"/>
|
||||
<add namespace="System.Web.Mvc"/>
|
||||
<add namespace="System.Web.Mvc.Ajax"/>
|
||||
<add namespace="System.Web.Mvc.Html"/>
|
||||
<add namespace="System.Web.Routing"/>
|
||||
<add namespace="System.Linq"/>
|
||||
<add namespace="System.Collections.Generic"/>
|
||||
<add namespace="System.Web.WebPages"/>
|
||||
<add namespace="Orchard.Mvc.Html"/>
|
||||
</namespaces>
|
||||
</pages>
|
||||
@@ -103,12 +104,13 @@
|
||||
|
||||
<pages>
|
||||
<namespaces>
|
||||
<add namespace="System.Collections.Generic"/>
|
||||
<add namespace="System.Linq"/>
|
||||
<add namespace="System.Web.Mvc"/>
|
||||
<add namespace="System.Web.Mvc.Ajax"/>
|
||||
<add namespace="System.Web.Mvc.Html"/>
|
||||
<add namespace="System.Web.Routing"/>
|
||||
<add namespace="System.Linq"/>
|
||||
<add namespace="System.Collections.Generic"/>
|
||||
<add namespace="System.Web.WebPages"/>
|
||||
<add namespace="Orchard.Mvc.Html"/>
|
||||
</namespaces>
|
||||
</pages>
|
||||
|
@@ -1,6 +1,8 @@
|
||||
@using Orchard.ContentManagement
|
||||
@using Orchard.MediaLibrary.Models
|
||||
@using Orchard.Azure.MediaServices.Models;
|
||||
@using Newtonsoft.Json;
|
||||
|
||||
@{
|
||||
Style.Include("cloudmedia-videoplayer.css", "cloudmedia-videoplayer.min.css");
|
||||
|
||||
|
@@ -14,15 +14,14 @@
|
||||
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=5.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
|
||||
<pages pageBaseType="Orchard.Mvc.ViewEngines.Razor.WebViewPage">
|
||||
<namespaces>
|
||||
<add namespace="System.Collections.Generic"/>
|
||||
<add namespace="System.Linq"/>
|
||||
<add namespace="System.Web.Mvc"/>
|
||||
<add namespace="System.Web.Mvc.Ajax"/>
|
||||
<add namespace="System.Web.Mvc.Html"/>
|
||||
<add namespace="System.Web.Routing"/>
|
||||
<add namespace="System.Linq"/>
|
||||
<add namespace="System.Web.WebPages"/>
|
||||
<add namespace="System.Collections.Generic"/>
|
||||
<add namespace="Orchard.Mvc.Html"/>
|
||||
<add namespace="Newtonsoft.Json"/>
|
||||
</namespaces>
|
||||
</pages>
|
||||
</system.web.webPages.razor>
|
||||
|
@@ -103,6 +103,7 @@
|
||||
<ItemGroup>
|
||||
<Compile Include="Services\Environment\Configuration\DefaultPlatformConfigurationAccessor.cs" />
|
||||
<Compile Include="Services\Environment\Configuration\IPlatformConfigurationAccessor.cs" />
|
||||
<Compile Include="Services\Environment\Configuration\PlatformConfiguration.cs" />
|
||||
<Compile Include="Services\TaskLease\AzureMachineNameProvider.cs" />
|
||||
<Content Include="Web.config" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
|
@@ -6,11 +6,11 @@ namespace Orchard.Azure.Services.Caching {
|
||||
|
||||
public class CacheClientConfiguration {
|
||||
|
||||
public static CacheClientConfiguration FromPlatformConfiguration(string tenant, string settingNamePrefix, IPlatformConfigurationAccessor pca) {
|
||||
public static CacheClientConfiguration FromPlatformConfiguration(string tenant, string settingNamePrefix) {
|
||||
return new CacheClientConfiguration {
|
||||
HostIdentifier = pca.GetSetting(Constants.CacheHostIdentifierSettingName, tenant, settingNamePrefix),
|
||||
CacheName = pca.GetSetting(Constants.CacheCacheNameSettingName, tenant, settingNamePrefix),
|
||||
AuthorizationToken = pca.GetSetting(Constants.CacheAuthorizationTokenSettingName, tenant, settingNamePrefix),
|
||||
HostIdentifier = PlatformConfiguration.GetSetting(Constants.CacheHostIdentifierSettingName, tenant, settingNamePrefix),
|
||||
CacheName = PlatformConfiguration.GetSetting(Constants.CacheCacheNameSettingName, tenant, settingNamePrefix),
|
||||
AuthorizationToken = PlatformConfiguration.GetSetting(Constants.CacheAuthorizationTokenSettingName, tenant, settingNamePrefix),
|
||||
};
|
||||
}
|
||||
|
||||
|
@@ -1,6 +1,5 @@
|
||||
using Microsoft.ApplicationServer.Caching;
|
||||
using NHibernate.Cache;
|
||||
using Orchard.Azure.Services.Environment.Configuration;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
@@ -9,11 +8,6 @@ namespace Orchard.Azure.Services.Caching.Database {
|
||||
public class AzureCacheProvider : ICacheProvider {
|
||||
|
||||
private DataCache _dataCache;
|
||||
private readonly IPlatformConfigurationAccessor _pca;
|
||||
|
||||
public AzureCacheProvider(IPlatformConfigurationAccessor pca) {
|
||||
_pca = pca;
|
||||
}
|
||||
|
||||
public ICache BuildCache(string regionName, IDictionary<string, string> properties) {
|
||||
|
||||
@@ -45,7 +39,7 @@ namespace Orchard.Azure.Services.Caching.Database {
|
||||
if (properties.TryGetValue("compression_enabled", out enableCompressionString))
|
||||
enableCompression = Boolean.Parse(enableCompressionString);
|
||||
|
||||
configuration = CacheClientConfiguration.FromPlatformConfiguration(tenantName, Constants.DatabaseCacheSettingNamePrefix, _pca);
|
||||
configuration = CacheClientConfiguration.FromPlatformConfiguration(tenantName, Constants.DatabaseCacheSettingNamePrefix);
|
||||
configuration.CompressionIsEnabled = enableCompression;
|
||||
configuration.Validate();
|
||||
}
|
||||
|
@@ -18,7 +18,7 @@ namespace Orchard.Azure.Services.Caching.Output {
|
||||
private readonly DataCache _cache;
|
||||
private readonly string _regionAlphaNumeric;
|
||||
|
||||
public AzureOutputCacheStorageProvider(ShellSettings shellSettings, IAzureOutputCacheHolder cacheHolder, IPlatformConfigurationAccessor pca) {
|
||||
public AzureOutputCacheStorageProvider(ShellSettings shellSettings, IAzureOutputCacheHolder cacheHolder) {
|
||||
|
||||
var region = shellSettings.Name;
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace Orchard.Azure.Services.Caching.Output {
|
||||
CacheClientConfiguration cacheConfig;
|
||||
|
||||
try {
|
||||
cacheConfig = CacheClientConfiguration.FromPlatformConfiguration(shellSettings.Name, Constants.OutputCacheSettingNamePrefix, pca);
|
||||
cacheConfig = CacheClientConfiguration.FromPlatformConfiguration(shellSettings.Name, Constants.OutputCacheSettingNamePrefix);
|
||||
cacheConfig.Validate();
|
||||
}
|
||||
catch (Exception ex) {
|
||||
|
@@ -6,24 +6,15 @@ namespace Orchard.Azure.Services.Environment.Configuration {
|
||||
public class DefaultPlatformConfigurationAccessor : IPlatformConfigurationAccessor {
|
||||
|
||||
/// <summary>
|
||||
/// Trying to read a setting from the following sources in the following order (with and then without tenant name prefix):
|
||||
/// CloudConfigurationManager, ConnectionStrings, AppSettings.
|
||||
/// Trying to read a setting using the default implementation.
|
||||
/// </summary>
|
||||
/// <param name="name">The name of the setting to read.</param>
|
||||
/// <param name="tenant">The current tenant's name.</param>
|
||||
/// <param name="namePrefix">An optional prefix to prepend the setting name with.</param>
|
||||
/// <returns>The value of the setting if found in any of the available sources, otherwise null.</returns>
|
||||
/// <see cref="PlatformConfiguration" />
|
||||
public string GetSetting(string name, string tenant, string namePrefix = null) {
|
||||
var tenantName = tenant + ":" + (namePrefix ?? string.Empty) + name;
|
||||
var fallbackName = (namePrefix ?? string.Empty) + name;
|
||||
|
||||
var settingFromCloudConfiguration = CloudConfigurationManager.GetSetting(tenantName) ?? CloudConfigurationManager.GetSetting(fallbackName);
|
||||
if (!string.IsNullOrEmpty(settingFromCloudConfiguration)) return settingFromCloudConfiguration;
|
||||
|
||||
var settingFromConnectionStrings = ConfigurationManager.ConnectionStrings[tenantName] ?? ConfigurationManager.ConnectionStrings[fallbackName];
|
||||
if (settingFromConnectionStrings != null) return settingFromConnectionStrings.ConnectionString;
|
||||
|
||||
return ConfigurationManager.AppSettings[tenantName] ?? ConfigurationManager.AppSettings[fallbackName];
|
||||
return PlatformConfiguration.GetSetting(name, tenant, namePrefix);
|
||||
}
|
||||
}
|
||||
}
|
@@ -4,6 +4,7 @@
|
||||
|
||||
/// <summary>
|
||||
/// Reads a setting using the available implementation(s).
|
||||
/// Implementations other than DefaultPlatformConfigurationAccessor do not have any effect on the behavior of caching services.
|
||||
/// </summary>
|
||||
/// <param name="name">The name of the setting to read.</param>
|
||||
/// <param name="tenant">The current tenant's name.</param>
|
||||
|
@@ -0,0 +1,29 @@
|
||||
using Microsoft.WindowsAzure;
|
||||
using System.Configuration;
|
||||
|
||||
namespace Orchard.Azure.Services.Environment.Configuration {
|
||||
|
||||
public static class PlatformConfiguration {
|
||||
|
||||
/// <summary>
|
||||
/// Trying to read a setting from the following sources in the following order (with and then without tenant name prefix):
|
||||
/// CloudConfigurationManager, ConnectionStrings, AppSettings.
|
||||
/// </summary>
|
||||
/// <param name="name">The name of the setting to read.</param>
|
||||
/// <param name="tenant">The current tenant's name.</param>
|
||||
/// <param name="namePrefix">An optional prefix to prepend the setting name with.</param>
|
||||
/// <returns>The value of the setting if found in any of the available sources, otherwise null.</returns>
|
||||
public static string GetSetting(string name, string tenant, string namePrefix = null) {
|
||||
var tenantName = tenant + ":" + (namePrefix ?? string.Empty) + name;
|
||||
var fallbackName = (namePrefix ?? string.Empty) + name;
|
||||
|
||||
var settingFromCloudConfiguration = CloudConfigurationManager.GetSetting(tenantName) ?? CloudConfigurationManager.GetSetting(fallbackName);
|
||||
if (!string.IsNullOrEmpty(settingFromCloudConfiguration)) return settingFromCloudConfiguration;
|
||||
|
||||
var settingFromConnectionStrings = ConfigurationManager.ConnectionStrings[tenantName] ?? ConfigurationManager.ConnectionStrings[fallbackName];
|
||||
if (settingFromConnectionStrings != null) return settingFromConnectionStrings.ConnectionString;
|
||||
|
||||
return ConfigurationManager.AppSettings[tenantName] ?? ConfigurationManager.AppSettings[fallbackName];
|
||||
}
|
||||
}
|
||||
}
|
@@ -20,13 +20,13 @@
|
||||
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=5.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
|
||||
<pages pageBaseType="Orchard.Mvc.ViewEngines.Razor.WebViewPage">
|
||||
<namespaces>
|
||||
<add namespace="System.Collections.Generic"/>
|
||||
<add namespace="System.Linq"/>
|
||||
<add namespace="System.Web.Mvc"/>
|
||||
<add namespace="System.Web.Mvc.Ajax"/>
|
||||
<add namespace="System.Web.Mvc.Html"/>
|
||||
<add namespace="System.Web.Routing"/>
|
||||
<add namespace="System.Web.WebPages"/>
|
||||
<add namespace="System.Linq"/>
|
||||
<add namespace="System.Collections.Generic"/>
|
||||
<add namespace="Orchard.Mvc.Html"/>
|
||||
</namespaces>
|
||||
</pages>
|
||||
@@ -81,15 +81,17 @@
|
||||
|
||||
<pages>
|
||||
<namespaces>
|
||||
<add namespace="System.Collections.Generic"/>
|
||||
<add namespace="System.Linq"/>
|
||||
<add namespace="System.Web.Mvc"/>
|
||||
<add namespace="System.Web.Mvc.Ajax"/>
|
||||
<add namespace="System.Web.Mvc.Html"/>
|
||||
<add namespace="System.Web.Routing"/>
|
||||
<add namespace="System.Linq"/>
|
||||
<add namespace="System.Collections.Generic"/>
|
||||
<add namespace="System.Web.WebPages"/>
|
||||
<add namespace="Orchard.Mvc.Html"/>
|
||||
</namespaces>
|
||||
</pages>
|
||||
|
||||
</system.web>
|
||||
|
||||
<system.webServer>
|
||||
|
Reference in New Issue
Block a user