Code cleanup

This commit is contained in:
Sebastien Ros 2013-08-30 12:50:39 -07:00
parent 5dbb82415b
commit bde2006dc7
13 changed files with 85 additions and 154 deletions

View File

@ -1,9 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace Orchard.Azure {
namespace Orchard.Azure {
public class Constants {
public const string ShellSettingsStorageConnectionStringSettingName = "Orchard.Azure.Settings.StorageConnectionString";

View File

@ -49,14 +49,6 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\lib\log4net\log4net.dll</HintPath>
</Reference>
<Reference Include="Microsoft.ApplicationServer.Caching.AzureClientHelper, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\lib\windowsazure\Microsoft.ApplicationServer.Caching.AzureClientHelper.dll</HintPath>
</Reference>
<Reference Include="Microsoft.ApplicationServer.Caching.AzureCommon, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\lib\windowsazure\Microsoft.ApplicationServer.Caching.AzureCommon.dll</HintPath>
</Reference>
<Reference Include="Microsoft.ApplicationServer.Caching.Client, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\lib\windowsazure\Microsoft.ApplicationServer.Caching.Client.dll</HintPath>
@ -65,62 +57,24 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\lib\windowsazure\Microsoft.ApplicationServer.Caching.Core.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Data.Edm, Version=5.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\lib\windowsazure\Microsoft.Data.Edm.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Data.OData, Version=5.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\lib\windowsazure\Microsoft.Data.OData.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Web.DistributedCache, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\lib\windowsazure\Microsoft.Web.DistributedCache.dll</HintPath>
</Reference>
<Reference Include="Microsoft.WindowsAzure.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\lib\windowsazure\Microsoft.WindowsAzure.Configuration.dll</HintPath>
</Reference>
<Reference Include="Microsoft.WindowsAzure.Diagnostics, Version=2.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\lib\windowsazure\Microsoft.WindowsAzure.Diagnostics.dll</HintPath>
</Reference>
<Reference Include="Microsoft.WindowsAzure.ServiceRuntime, Version=2.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\lib\windowsazure\Microsoft.WindowsAzure.ServiceRuntime.dll</HintPath>
</Reference>
<Reference Include="Microsoft.WindowsAzure.Storage, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\lib\windowsazure\Microsoft.WindowsAzure.Storage.dll</HintPath>
</Reference>
<Reference Include="Microsoft.WindowsFabric.Common, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\lib\windowsazure\Microsoft.WindowsFabric.Common.dll</HintPath>
</Reference>
<Reference Include="Microsoft.WindowsFabric.Data.Common, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\lib\windowsazure\Microsoft.WindowsFabric.Data.Common.dll</HintPath>
</Reference>
<Reference Include="NHibernate, Version=3.3.1.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\lib\nhibernate\NHibernate.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.ComponentModel.DataAnnotations">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Web.DynamicData" />
<Reference Include="System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\lib\aspnetmvc\System.Web.Mvc.dll</HintPath>
</Reference>
<Reference Include="System.Web" />
<Reference Include="System.Web.Abstractions" />
<Reference Include="System.Web.Routing" />
<Reference Include="System.Xml" />
<Reference Include="System.Configuration" />
<Reference Include="System.Xml.Linq" />
</ItemGroup>
<ItemGroup>
<Content Include="Web.config" />
@ -132,10 +86,6 @@
<Project>{2D1D92BB-4555-4CBE-8D0E-63563D6CE4C6}</Project>
<Name>Orchard.Framework</Name>
</ProjectReference>
<ProjectReference Include="..\..\Core\Orchard.Core.csproj">
<Project>{9916839C-39FC-4CEB-A5AF-89CA7E87119F}</Project>
<Name>Orchard.Core</Name>
</ProjectReference>
<ProjectReference Include="..\Orchard.OutputCache\Orchard.OutputCache.csproj">
<Project>{6e444ff1-a47c-4cf6-bb3f-507c8ebd776d}</Project>
<Name>Orchard.OutputCache</Name>
@ -147,7 +97,7 @@
<Compile Include="Services\Caching\Database\AzureCacheClient.cs" />
<Compile Include="Services\Caching\Database\AzureCacheConfiguration.cs" />
<Compile Include="Services\Caching\Database\AzureCacheProvider.cs" />
<Compile Include="Services\Caching\Database\AzureCacheRecord.cs" />
<Compile Include="Services\Caching\Database\Models\AzureCacheRecord.cs" />
<Compile Include="Services\Caching\Output\AzureOutputCacheStorageProvider.cs" />
<Compile Include="Services\Environment\Configuration\AzureBlobShellSettingsManager.cs" />
<Compile Include="Services\Environment\Configuration\PlatformConfiguration.cs" />

View File

@ -2,10 +2,6 @@
using Orchard.Azure.Services.Environment.Configuration;
using Orchard.Environment.Configuration;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security;
using System.Web;
namespace Orchard.Azure.Services.Caching {
@ -14,13 +10,13 @@ namespace Orchard.Azure.Services.Caching {
public static CacheClientConfiguration FromPlatformConfiguration(ShellSettings shellSettings, string settingNamePrefix) {
var portString = PlatformConfiguration.GetSetting(Constants.CachePortSettingName, shellSettings, settingNamePrefix);
var isSharedCachingString = PlatformConfiguration.GetSetting(Constants.CacheIsSharedCachingSettingName, shellSettings, settingNamePrefix);
return new CacheClientConfiguration() {
return new CacheClientConfiguration {
HostIdentifier = PlatformConfiguration.GetSetting(Constants.CacheHostIdentifierSettingName, shellSettings, settingNamePrefix),
CacheName = PlatformConfiguration.GetSetting(Constants.CacheCacheNameSettingName, shellSettings, settingNamePrefix),
Hostname = PlatformConfiguration.GetSetting(Constants.CacheHostnameSettingName, shellSettings, settingNamePrefix),
Port = String.IsNullOrWhiteSpace(portString) ? 0 : Int32.Parse(portString),
AuthorizationToken = PlatformConfiguration.GetSetting(Constants.CacheAuthorizationTokenSettingName, shellSettings, settingNamePrefix),
IsSharedCaching = String.IsNullOrWhiteSpace(isSharedCachingString) ? false : Boolean.Parse(isSharedCachingString)
IsSharedCaching = !String.IsNullOrWhiteSpace(isSharedCachingString) && Boolean.Parse(isSharedCachingString)
};
}
@ -66,36 +62,37 @@ namespace Orchard.Azure.Services.Caching {
}
public void Validate() {
if (AutodiscoverIsEnabled) {
if (String.IsNullOrWhiteSpace(HostIdentifier))
throw new Exception("AutoDiscover mode is detected but HostIdentifier is missing or empty.");
if (AutodiscoverIsEnabled && String.IsNullOrWhiteSpace(HostIdentifier)) {
throw new Exception("AutoDiscover mode is detected but HostIdentifier is missing or empty.");
}
}
public DataCache CreateCache() {
var dataCacheFactoryConfiguration = new DataCacheFactoryConfiguration() {
var dataCacheFactoryConfiguration = new DataCacheFactoryConfiguration {
MaxConnectionsToServer = 32,
UseLegacyProtocol = false,
IsCompressionEnabled = CompressionIsEnabled
};
if (AutodiscoverIsEnabled)
if (AutodiscoverIsEnabled) {
dataCacheFactoryConfiguration.AutoDiscoverProperty = new DataCacheAutoDiscoverProperty(true, HostIdentifier);
}
else {
dataCacheFactoryConfiguration.Servers = new[] { new DataCacheServerEndpoint(Hostname, Port) };
dataCacheFactoryConfiguration.Servers = new[] {new DataCacheServerEndpoint(Hostname, Port)};
dataCacheFactoryConfiguration.SecurityProperties = new DataCacheSecurity(AuthorizationToken);
}
var dataCacheFactory = new DataCacheFactory(dataCacheFactoryConfiguration);
if (IsSharedCaching || String.IsNullOrEmpty(CacheName))
if (IsSharedCaching || String.IsNullOrEmpty(CacheName)) {
return dataCacheFactory.GetDefaultCache();
}
return dataCacheFactory.GetCache(CacheName);
}
public override string ToString() {
string key = String.Format("{0}_{1}_{2}_{3}_{4}_{5}_{6}", HostIdentifier, CacheName, Hostname, Port, AuthorizationToken, IsSharedCaching, CompressionIsEnabled);
var key = HostIdentifier + "_" + CacheName + "_" + Hostname + "_" + Port + "_" + AuthorizationToken + "_" + IsSharedCaching + "_" + CompressionIsEnabled;
return key;
}
}

View File

@ -1,6 +1,5 @@
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Globalization;
using Microsoft.ApplicationServer.Caching;
using NHibernate;
using NHibernate.Cache;
@ -13,93 +12,106 @@ namespace Orchard.Azure.Services.Caching.Database {
_logger = LoggerProvider.LoggerFor(typeof(AzureCacheClient));
_cache = cache;
_isSharedCaching = isSharedCaching;
_region = region ?? _defaultRegion;
_region = region ?? DefaultRegion;
// Azure Cache supports only alphanumeric strings for regions and
// Orchard can get a lot more creative than that. Remove all non
// alphanumering characters from the region, and append the hash code
// of the original string to mitigate the risk of two distinct original
// region strings yielding the same transformed region string.
_regionAlphaNumeric = new String(Array.FindAll(_region.ToCharArray(), c => Char.IsLetterOrDigit(c))) + _region.GetHashCode().ToString();
_regionAlphaNumeric = new String(Array.FindAll(_region.ToCharArray(), Char.IsLetterOrDigit)) + _region.GetHashCode().ToString(CultureInfo.InvariantCulture);
_expirationTime = expirationTime;
if (!isSharedCaching)
if (!isSharedCaching) {
_cache.CreateRegion(_regionAlphaNumeric);
}
//_lockHandleDictionary = new ConcurrentDictionary<object, DataCacheLockHandle>();
//_lockTimeout = TimeSpan.FromSeconds(30);
if (_logger.IsDebugEnabled)
if (_logger.IsDebugEnabled) {
_logger.DebugFormat("Created an AzureCacheClient for region '{0}' (original region '{1}').", _regionAlphaNumeric, _region);
}
}
private const string _defaultRegion = "NHibernate";
private const string DefaultRegion = "NHibernate";
private readonly IInternalLogger _logger;
private readonly DataCache _cache;
private readonly bool _isSharedCaching;
private readonly string _region;
private readonly string _regionAlphaNumeric;
private readonly TimeSpan? _expirationTime;
//private readonly ConcurrentDictionary<object, DataCacheLockHandle> _lockHandleDictionary;
//private readonly TimeSpan _lockTimeout;
#region ICache Members
public object Get(object key) {
if (key == null)
throw new ArgumentNullException("key", "The parameter 'key' must not be null.");
if (_logger.IsDebugEnabled)
if (_logger.IsDebugEnabled) {
_logger.DebugFormat("Get() invoked with key='{0}' in region '{1}'.", key, _regionAlphaNumeric);
}
if (_isSharedCaching)
if (_isSharedCaching) {
return _cache.Get(GetSharedCachingKey(key));
}
return _cache.Get(key.ToString(), _regionAlphaNumeric);
}
public void Put(object key, object value) {
if (key == null)
if (key == null) {
throw new ArgumentNullException("key", "The parameter 'key' must not be null.");
if (value == null)
}
if (value == null) {
throw new ArgumentNullException("value", "The parameter 'value' must not be null.");
}
if (_logger.IsDebugEnabled)
if (_logger.IsDebugEnabled) {
_logger.DebugFormat("Put() invoked with key='{0}' and value='{1}' in region '{2}'.", key, value, _regionAlphaNumeric);
}
if (_isSharedCaching)
if (_isSharedCaching) {
_cache.Put(GetSharedCachingKey(key), value);
else if (_expirationTime.HasValue)
}
else if (_expirationTime.HasValue) {
_cache.Put(key.ToString(), value, _expirationTime.Value, _regionAlphaNumeric);
else
}
else {
_cache.Put(key.ToString(), value, _regionAlphaNumeric);
}
}
public void Remove(object key) {
if (key == null)
if (key == null) {
throw new ArgumentNullException("key", "The parameter 'key' must not be null.");
}
if (_logger.IsDebugEnabled)
if (_logger.IsDebugEnabled) {
_logger.DebugFormat("Remove() invoked with key='{0}' in region '{1}'.", key, _regionAlphaNumeric);
}
if (_isSharedCaching)
if (_isSharedCaching) {
_cache.Remove(key.ToString());
}
_cache.Remove(key.ToString(), _regionAlphaNumeric);
}
public void Clear() {
if (_logger.IsDebugEnabled)
if (_logger.IsDebugEnabled) {
_logger.DebugFormat("Clear() invoked in region '{0}'.", _regionAlphaNumeric);
if (_isSharedCaching)
}
if (_isSharedCaching) {
return; // Can't remove an individual region with Shared Caching.
}
_cache.ClearRegion(_regionAlphaNumeric);
}
public void Destroy() {
if (_logger.IsDebugEnabled)
if (_logger.IsDebugEnabled) {
_logger.DebugFormat("Destroy() invoked in region '{0}'.", _regionAlphaNumeric);
}
Clear();
}
@ -159,8 +171,9 @@ namespace Orchard.Azure.Services.Caching.Database {
// TODO: Try to understand what this is for and how it's used.
public long NextTimestamp() {
if (_logger.IsDebugEnabled)
if (_logger.IsDebugEnabled) {
_logger.DebugFormat("NextTimestamp() invoked in region '{0}'.", _regionAlphaNumeric);
}
return Timestamper.Next();
}
@ -181,8 +194,6 @@ namespace Orchard.Azure.Services.Caching.Database {
}
}
#endregion
private string GetSharedCachingKey(object key) {
return String.Format("{0}_{1}", _region, key);
}

View File

@ -1,7 +1,5 @@
using System;
using System.Linq;
using NHibernate.Cfg.Loquacious;
using Orchard;
using Orchard.Data;
using Orchard.Environment.Configuration;
using Orchard.Environment.Extensions;
@ -15,8 +13,7 @@ namespace Orchard.Azure.Services.Caching.Database {
public static CacheClientConfiguration CacheClientConfiguration;
public AzureCacheConfiguration(ShellSettings shellSettings)
: base() {
public AzureCacheConfiguration(ShellSettings shellSettings) {
try {
CacheClientConfiguration = CacheClientConfiguration.FromPlatformConfiguration(shellSettings, Constants.DatabaseCacheSettingNamePrefix);

View File

@ -1,5 +1,5 @@
using System.Collections.Concurrent;
using System.Collections.Generic;
using Microsoft.WindowsAzure.ServiceRuntime;
using NHibernate.Cache;
using System;
using Microsoft.ApplicationServer.Caching;
@ -9,27 +9,21 @@ namespace Orchard.Azure.Services.Caching.Database {
public class AzureCacheProvider : ICacheProvider {
#region DataCache repository
private static IDictionary<string, DataCache> _cacheDictionary = new Dictionary<string, DataCache>();
private static readonly IDictionary<string, DataCache> _cacheDictionary = new ConcurrentDictionary<string, DataCache>();
private static DataCache GetCache(IInternalLogger logger, CacheClientConfiguration config) {
string key = config.ToString();
if (!_cacheDictionary.ContainsKey(key)) {
if (logger.IsDebugEnabled)
logger.DebugFormat("Creating new DataCache with key '{0}'.", key);
logger.DebugFormat("Creating new DataCache with key '{0}'.", key);
_cacheDictionary[key] = AzureCacheConfiguration.CacheClientConfiguration.CreateCache();
}
else {
if (logger.IsDebugEnabled)
logger.DebugFormat("Reusing existing DataCache with key '{0}'.", key);
logger.DebugFormat("Reusing existing DataCache with key '{0}'.", key);
}
return _cacheDictionary[key];
}
#endregion
public AzureCacheProvider() {
_logger = LoggerProvider.LoggerFor(typeof(AzureCacheProvider));
}
@ -39,10 +33,8 @@ namespace Orchard.Azure.Services.Caching.Database {
#region ICacheProvider Members
public ICache BuildCache(string regionName, IDictionary<string, string> properties) {
bool enableCompression = false;
string enableCompressionString;
if (properties.TryGetValue("compression_enabled", out enableCompressionString))
enableCompression = Boolean.Parse(enableCompressionString);
properties.TryGetValue("compression_enabled", out enableCompressionString);
// Using static fields to communicate host identifier and cache name from AzureCacheConfiguration to
// this class might cause problems in multi-tenancy scenarios when tenants have different settings
@ -51,8 +43,9 @@ namespace Orchard.Azure.Services.Caching.Database {
TimeSpan? expiration = null;
string expirationString;
if (properties.TryGetValue("expiration", out expirationString) || properties.TryGetValue(global::NHibernate.Cfg.Environment.CacheDefaultExpiration, out expirationString))
if (properties.TryGetValue("expiration", out expirationString) || properties.TryGetValue(NHibernate.Cfg.Environment.CacheDefaultExpiration, out expirationString)) {
expiration = TimeSpan.FromSeconds(Int32.Parse(expirationString));
}
return new AzureCacheClient(cache, AzureCacheConfiguration.CacheClientConfiguration.IsSharedCaching, regionName, expiration);
}

View File

@ -1,20 +1,13 @@
using Orchard.Environment.Extensions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace Orchard.Azure.Services.Caching.Database.Models {
/// <summary>
/// Fake record in order to force the mappings to be updated
/// whenever the feature is enabled/disabled.
/// </summary>
[OrchardFeature(Constants.DatabaseCacheFeatureName)]
public class AzureCacheRecord {
public virtual int Id {
get;
set;
}
}
using Orchard.Environment.Extensions;
namespace Orchard.Azure.Services.Caching.Database.Models {
/// <summary>
/// Fake record in order to force the mappings to be updated
/// whenever the feature is enabled/disabled.
/// </summary>
[OrchardFeature(Constants.DatabaseCacheFeatureName)]
public class AzureCacheRecord {
public virtual int Id { get; set; }
}
}

View File

@ -14,8 +14,7 @@ namespace Orchard.Azure.Services.Caching.Output {
[OrchardSuppressDependency("Orchard.OutputCache.Services.DefaultCacheStorageProvider")]
public class AzureOutputCacheStorageProvider : Component, IOutputCacheStorageProvider {
public AzureOutputCacheStorageProvider(ShellSettings shellSettings)
: base() {
public AzureOutputCacheStorageProvider(ShellSettings shellSettings) {
try {
_cacheConfig = CacheClientConfiguration.FromPlatformConfiguration(shellSettings, Constants.OutputCacheSettingNamePrefix);

View File

@ -24,8 +24,7 @@ namespace Orchard.Azure.Services.Environment.Configuration {
private readonly AzureFileSystem _fileSystem;
private readonly IShellSettingsManagerEventHandler _events;
public AzureBlobShellSettingsManager(IMimeTypeProvider mimeTypeProvider, IShellSettingsManagerEventHandler events)
: base() {
public AzureBlobShellSettingsManager(IMimeTypeProvider mimeTypeProvider, IShellSettingsManagerEventHandler events) {
_fileSystem = new AzureFileSystem(CloudConfigurationManager.GetSetting(Constants.ShellSettingsStorageConnectionStringSettingName), Constants.ShellSettingsContainerName, String.Empty, true, mimeTypeProvider);
_events = events;
}

View File

@ -1,9 +1,6 @@
using Microsoft.WindowsAzure;
using Orchard.Environment.Configuration;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace Orchard.Azure.Services.Environment.Configuration {
@ -18,8 +15,8 @@ namespace Orchard.Azure.Services.Environment.Configuration {
/// <param name="namePrefix">An optional prefix to prepend the setting name with.</param>
/// <returns>The value of the setting if found with or without tenant name prefix, otherwise null.</returns>
public static string GetSetting(string name, ShellSettings shellSettings, string namePrefix = null) {
var tenantName = String.Format("{0}:{1}{2}", shellSettings.Name, namePrefix, name);
var fallbackName = String.Format("{0}{1}", namePrefix, name);
var tenantName = shellSettings.Name + ":" + namePrefix + name;
var fallbackName = namePrefix + name;
return CloudConfigurationManager.GetSetting(tenantName) ?? CloudConfigurationManager.GetSetting(fallbackName);
}
}

View File

@ -2,7 +2,6 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Microsoft.WindowsAzure;
using Microsoft.WindowsAzure.Storage;
using Microsoft.WindowsAzure.Storage.Blob;
using Orchard.FileSystems.Media;
@ -82,8 +81,9 @@ namespace Orchard.Azure.Services.FileSystems {
private static string ConvertToRelativeUriPath(string path) {
var newPath = path.Replace(@"\", "/");
if (newPath.StartsWith("/") || newPath.StartsWith("http://") || newPath.StartsWith("https://"))
if (newPath.StartsWith("/") || newPath.StartsWith("http://") || newPath.StartsWith("https://")) {
throw new ArgumentException("Path must be relative");
}
return newPath;
}
@ -141,8 +141,9 @@ namespace Orchard.Azure.Services.FileSystems {
string prefix = Combine(Combine(Container.Name, _root), path);
if (!prefix.EndsWith("/"))
if (!prefix.EndsWith("/")) {
prefix += "/";
}
return BlobClient.ListBlobs(prefix, true)
.OfType<CloudBlockBlob>()

View File

@ -34,8 +34,9 @@ namespace Orchard.Azure.Services.FileSystems {
}
public static bool DirectoryExists(this CloudBlobContainer container, string path) {
if (String.IsNullOrEmpty(path) || path.Trim() == String.Empty)
if (String.IsNullOrEmpty(path) || path.Trim() == String.Empty) {
throw new ArgumentException("Path can't be empty");
}
return container.GetDirectoryReference(path).ListBlobs().Any();
}

View File

@ -1,6 +1,4 @@
using System;
using Microsoft.WindowsAzure.Diagnostics;
using log4net.Appender;
using log4net.Appender;
using log4net.Core;
using System.Diagnostics;