@@ -69,17 +69,19 @@ public FileSystemVirtualPathProvider(string pathPrefix, Lazy<IFileSystem> fileSy
6969 /// <param name="pathPrefix">
7070 /// The path prefix.
7171 /// </param>
72+ /// <param name="fileSystem">
73+ /// The file system.
74+ /// </param>
7275 /// <exception cref="ArgumentNullException">
7376 /// Thrown if <paramref name="pathPrefix"/> is null.
7477 /// </exception>
75- public static void Configure ( string pathPrefix = Constants . DefaultMediaRoute )
78+ public static void Configure ( string pathPrefix , Lazy < IFileSystem > fileSystem )
7679 {
7780 if ( string . IsNullOrEmpty ( pathPrefix ) )
7881 {
7982 throw new ArgumentNullException ( nameof ( pathPrefix ) ) ;
8083 }
8184
82- Lazy < IFileSystem > fileSystem = new Lazy < IFileSystem > ( ( ) => Current . MediaFileSystem . Unwrap ( ) ) ;
8385 FileSystemVirtualPathProvider provider = new FileSystemVirtualPathProvider ( pathPrefix , fileSystem ) ;
8486
8587 // The standard HostingEnvironment.RegisterVirtualPathProvider(virtualPathProvider) method is ignored when
@@ -113,6 +115,21 @@ public static void Configure(string pathPrefix = Constants.DefaultMediaRoute)
113115 }
114116 }
115117
118+ /// <summary>
119+ /// Configures the virtual path provider.
120+ /// </summary>
121+ /// <param name="pathPrefix">
122+ /// The path prefix.
123+ /// </param>
124+ /// <exception cref="ArgumentNullException">
125+ /// Thrown if <paramref name="pathPrefix"/> is null.
126+ /// </exception>
127+ [ Obsolete ( "Use ConfigureMedia to set the media path, or pass a provider to set the path for any file system" ) ]
128+ public static void Configure ( string pathPrefix = Constants . DefaultMediaRoute )
129+ {
130+ ConfigureMedia ( pathPrefix ) ;
131+ }
132+
116133 /// <summary>
117134 /// Configures the virtual path provider for media.
118135 /// </summary>
@@ -122,7 +139,14 @@ public static void Configure(string pathPrefix = Constants.DefaultMediaRoute)
122139 [ SuppressMessage ( "StyleCop.CSharp.ReadabilityRules" , "SA1126:PrefixCallsCorrectly" , Justification = "Resharper seems drunk." ) ]
123140 public static void ConfigureMedia ( string pathPrefix = Constants . DefaultMediaRoute )
124141 {
125- Configure ( pathPrefix ) ;
142+ if ( string . IsNullOrEmpty ( pathPrefix ) )
143+ {
144+ throw new ArgumentNullException ( nameof ( pathPrefix ) ) ;
145+ }
146+
147+ Lazy < IFileSystem > fileSystem = new Lazy < IFileSystem > ( ( ) => Current . MediaFileSystem . Unwrap ( ) ) ;
148+
149+ Configure ( pathPrefix , fileSystem ) ;
126150 }
127151
128152 /// <summary>
@@ -142,6 +166,7 @@ public override bool FileExists(string virtualPath)
142166 }
143167
144168 string fileSystemPath = this . RemovePathPrefix ( path ) ;
169+
145170 return this . fileSystem . Value . FileExists ( fileSystemPath ) ;
146171 }
147172
@@ -156,6 +181,7 @@ public override bool FileExists(string virtualPath)
156181 public override VirtualFile GetFile ( string virtualPath )
157182 {
158183 string path = this . FormatVirtualPath ( virtualPath ) ;
184+
159185 if ( ! path . StartsWith ( this . pathPrefix , StringComparison . InvariantCultureIgnoreCase ) )
160186 {
161187 return base . GetFile ( virtualPath ) ;
0 commit comments