@@ -41,9 +41,9 @@ internal class AzureFileSystem : IFileSystem
41
41
private static readonly object Locker = new object ( ) ;
42
42
43
43
/// <summary>
44
- /// The singleton instance of <see cref="AzureFileSystem"/>.
44
+ /// A list of <see cref="AzureFileSystem"/>.
45
45
/// </summary>
46
- private static AzureFileSystem fileSystem ;
46
+ private static List < AzureFileSystem > fileSystems ;
47
47
48
48
/// <summary>
49
49
/// The root url.
@@ -66,7 +66,7 @@ internal class AzureFileSystem : IFileSystem
66
66
/// <exception cref="ArgumentNullException">
67
67
/// Thrown if <paramref name="containerName"/> is null or whitespace.
68
68
/// </exception>
69
- private AzureFileSystem ( string containerName , string rootUrl , string connectionString , int maxDays , bool useDefaultRoute )
69
+ internal AzureFileSystem ( string containerName , string rootUrl , string connectionString , int maxDays , bool useDefaultRoute )
70
70
{
71
71
if ( string . IsNullOrWhiteSpace ( containerName ) )
72
72
{
@@ -149,11 +149,11 @@ private AzureFileSystem(string containerName, string rootUrl, string connectionS
149
149
/// <param name="maxDays">The maximum number of days to cache blob items for in the browser.</param>
150
150
/// <param name="useDefaultRoute">Whether to use the default "media" route in the url independent of the blob container.</param>
151
151
/// <returns>The <see cref="AzureFileSystem"/></returns>
152
- public static AzureFileSystem GetInstance ( string containerName , string rootUrl , string connectionString , string maxDays , string useDefaultRoute )
152
+ public AzureFileSystem GetInstance ( string containerName , string rootUrl , string connectionString , string maxDays , string useDefaultRoute )
153
153
{
154
154
lock ( Locker )
155
155
{
156
- if ( fileSystem == null )
156
+ if ( fileSystems . SingleOrDefault ( fs => fs . ContainerName == containerName && fs . rootUrl == rootUrl ) == null )
157
157
{
158
158
int max ;
159
159
if ( ! int . TryParse ( maxDays , out max ) )
@@ -167,10 +167,19 @@ public static AzureFileSystem GetInstance(string containerName, string rootUrl,
167
167
defaultRoute = true ;
168
168
}
169
169
170
- fileSystem = new AzureFileSystem ( containerName , rootUrl , connectionString , max , defaultRoute ) ;
170
+ var fileSystem = new AzureFileSystem ( containerName , rootUrl , connectionString , max , defaultRoute ) ;
171
+
172
+ if ( fileSystems == null )
173
+ {
174
+ fileSystems = new List < AzureFileSystem > { fileSystem } ;
175
+ }
176
+ else
177
+ {
178
+ fileSystems . Add ( fileSystem ) ;
179
+ }
171
180
}
172
181
173
- return fileSystem ;
182
+ return fileSystems . SingleOrDefault ( fs => fs . ContainerName == containerName && fs . rootUrl == rootUrl ) ;
174
183
}
175
184
}
176
185
0 commit comments