6
6
namespace Our . Umbraco . FileSystemProviders . Azure
7
7
{
8
8
using System ;
9
- using System . Diagnostics . CodeAnalysis ;
10
9
using System . Reflection ;
11
10
using System . Web ;
12
11
using System . Web . Compilation ;
13
12
using System . Web . Hosting ;
14
- using global ::Umbraco . Core . Composing ;
15
13
using global ::Umbraco . Core . IO ;
16
14
17
15
/// <summary>
@@ -69,17 +67,19 @@ public FileSystemVirtualPathProvider(string pathPrefix, Lazy<IFileSystem> fileSy
69
67
/// <param name="pathPrefix">
70
68
/// The path prefix.
71
69
/// </param>
70
+ /// <param name="fileSystem">
71
+ /// The file system.
72
+ /// </param>
72
73
/// <exception cref="ArgumentNullException">
73
74
/// Thrown if <paramref name="pathPrefix"/> is null.
74
75
/// </exception>
75
- public static void Configure ( string pathPrefix = Constants . DefaultMediaRoute )
76
+ public static void Configure ( string pathPrefix , Lazy < IFileSystem > fileSystem )
76
77
{
77
78
if ( string . IsNullOrEmpty ( pathPrefix ) )
78
79
{
79
80
throw new ArgumentNullException ( nameof ( pathPrefix ) ) ;
80
81
}
81
82
82
- Lazy < IFileSystem > fileSystem = new Lazy < IFileSystem > ( ( ) => Current . MediaFileSystem . Unwrap ( ) ) ;
83
83
FileSystemVirtualPathProvider provider = new FileSystemVirtualPathProvider ( pathPrefix , fileSystem ) ;
84
84
85
85
// The standard HostingEnvironment.RegisterVirtualPathProvider(virtualPathProvider) method is ignored when
@@ -113,18 +113,6 @@ public static void Configure(string pathPrefix = Constants.DefaultMediaRoute)
113
113
}
114
114
}
115
115
116
- /// <summary>
117
- /// Configures the virtual path provider for media.
118
- /// </summary>
119
- /// <param name="pathPrefix">
120
- /// The path prefix.
121
- /// </param>
122
- [ SuppressMessage ( "StyleCop.CSharp.ReadabilityRules" , "SA1126:PrefixCallsCorrectly" , Justification = "Resharper seems drunk." ) ]
123
- public static void ConfigureMedia ( string pathPrefix = Constants . DefaultMediaRoute )
124
- {
125
- Configure ( pathPrefix ) ;
126
- }
127
-
128
116
/// <summary>
129
117
/// Gets a value that indicates whether a file exists in the virtual file system.
130
118
/// </summary>
@@ -142,6 +130,7 @@ public override bool FileExists(string virtualPath)
142
130
}
143
131
144
132
string fileSystemPath = this . RemovePathPrefix ( path ) ;
133
+
145
134
return this . fileSystem . Value . FileExists ( fileSystemPath ) ;
146
135
}
147
136
@@ -156,6 +145,7 @@ public override bool FileExists(string virtualPath)
156
145
public override VirtualFile GetFile ( string virtualPath )
157
146
{
158
147
string path = this . FormatVirtualPath ( virtualPath ) ;
148
+
159
149
if ( ! path . StartsWith ( this . pathPrefix , StringComparison . InvariantCultureIgnoreCase ) )
160
150
{
161
151
return base . GetFile ( virtualPath ) ;
0 commit comments