@@ -48,9 +48,9 @@ internal class AzureFileSystem : IFileSystem
48
48
private static readonly object Locker = new object ( ) ;
49
49
50
50
/// <summary>
51
- /// The singleton instance of <see cref="AzureFileSystem"/>.
51
+ /// A list of <see cref="AzureFileSystem"/>.
52
52
/// </summary>
53
- private static AzureFileSystem fileSystem ;
53
+ private static List < AzureFileSystem > fileSystems ;
54
54
55
55
/// <summary>
56
56
/// The root url.
@@ -73,7 +73,7 @@ internal class AzureFileSystem : IFileSystem
73
73
/// <exception cref="ArgumentNullException">
74
74
/// Thrown if <paramref name="containerName"/> is null or whitespace.
75
75
/// </exception>
76
- private AzureFileSystem ( string containerName , string rootUrl , string connectionString , int maxDays , bool useDefaultRoute )
76
+ internal AzureFileSystem ( string containerName , string rootUrl , string connectionString , int maxDays , bool useDefaultRoute )
77
77
{
78
78
if ( string . IsNullOrWhiteSpace ( containerName ) )
79
79
{
@@ -156,11 +156,11 @@ private AzureFileSystem(string containerName, string rootUrl, string connectionS
156
156
/// <param name="maxDays">The maximum number of days to cache blob items for in the browser.</param>
157
157
/// <param name="useDefaultRoute">Whether to use the default "media" route in the url independent of the blob container.</param>
158
158
/// <returns>The <see cref="AzureFileSystem"/></returns>
159
- public static AzureFileSystem GetInstance ( string containerName , string rootUrl , string connectionString , string maxDays , string useDefaultRoute )
159
+ public AzureFileSystem GetInstance ( string containerName , string rootUrl , string connectionString , string maxDays , string useDefaultRoute )
160
160
{
161
161
lock ( Locker )
162
162
{
163
- if ( fileSystem == null )
163
+ if ( fileSystems . SingleOrDefault ( fs => fs . ContainerName == containerName && fs . rootUrl == rootUrl ) == null )
164
164
{
165
165
int max ;
166
166
if ( ! int . TryParse ( maxDays , out max ) )
@@ -174,10 +174,19 @@ public static AzureFileSystem GetInstance(string containerName, string rootUrl,
174
174
defaultRoute = true ;
175
175
}
176
176
177
- fileSystem = new AzureFileSystem ( containerName , rootUrl , connectionString , max , defaultRoute ) ;
177
+ var fileSystem = new AzureFileSystem ( containerName , rootUrl , connectionString , max , defaultRoute ) ;
178
+
179
+ if ( fileSystems == null )
180
+ {
181
+ fileSystems = new List < AzureFileSystem > { fileSystem } ;
182
+ }
183
+ else
184
+ {
185
+ fileSystems . Add ( fileSystem ) ;
186
+ }
178
187
}
179
188
180
- return fileSystem ;
189
+ return fileSystems . SingleOrDefault ( fs => fs . ContainerName == containerName && fs . rootUrl == rootUrl ) ;
181
190
}
182
191
}
183
192
0 commit comments