mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-04-05 21:01:35 +08:00
Create ToAppRelative wrapper in IVirtualPathProvider
--HG-- branch : dev
This commit is contained in:
parent
27c945d498
commit
9198be72ed
@ -29,6 +29,10 @@ namespace Orchard.Tests.Stubs {
|
||||
return Path.Combine(paths).Replace(Path.DirectorySeparatorChar, '/');
|
||||
}
|
||||
|
||||
public string ToAppRelative(string virtualPath) {
|
||||
return "~/" + ToFileSystemPath(virtualPath);
|
||||
}
|
||||
|
||||
public string MapPath(string virtualPath) {
|
||||
throw new NotImplementedException("Mapping to a physical file is not supported in Unit Test with this stub.");
|
||||
}
|
||||
|
@ -48,10 +48,9 @@ namespace Orchard.Environment.Extensions.Loaders {
|
||||
}
|
||||
|
||||
public override IEnumerable<string> GetFileDependencies(DependencyDescriptor dependency, string virtualPath){
|
||||
var path1 = virtualPath.StartsWith("~") ? virtualPath : "~" + virtualPath;
|
||||
var path2 = dependency.VirtualPath.StartsWith("~") ? dependency.VirtualPath : "~" + dependency.VirtualPath;
|
||||
virtualPath = _virtualPathProvider.ToAppRelative(virtualPath);
|
||||
|
||||
if (StringComparer.OrdinalIgnoreCase.Equals(path1, path2)) {
|
||||
if (StringComparer.OrdinalIgnoreCase.Equals(virtualPath, dependency.VirtualPath)) {
|
||||
return GetSourceFiles(virtualPath);
|
||||
}
|
||||
return base.GetFileDependencies(dependency, virtualPath);
|
||||
|
@ -17,7 +17,7 @@ namespace Orchard.FileSystems.VirtualPath {
|
||||
.GetDirectory(path)
|
||||
.Files
|
||||
.OfType<VirtualFile>()
|
||||
.Select(f => VirtualPathUtility.ToAppRelative(f.VirtualPath));
|
||||
.Select(f => ToAppRelative(f.VirtualPath));
|
||||
}
|
||||
|
||||
public IEnumerable<string> ListDirectories(string path) {
|
||||
@ -26,13 +26,17 @@ namespace Orchard.FileSystems.VirtualPath {
|
||||
.GetDirectory(path)
|
||||
.Directories
|
||||
.OfType<VirtualDirectory>()
|
||||
.Select(d => VirtualPathUtility.ToAppRelative(d.VirtualPath));
|
||||
.Select(d => ToAppRelative(d.VirtualPath));
|
||||
}
|
||||
|
||||
public string Combine(params string[] paths) {
|
||||
return Path.Combine(paths).Replace(Path.DirectorySeparatorChar, '/');
|
||||
}
|
||||
|
||||
public string ToAppRelative(string virtualPath) {
|
||||
return VirtualPathUtility.ToAppRelative(virtualPath);
|
||||
}
|
||||
|
||||
public Stream OpenFile(string virtualPath) {
|
||||
return HostingEnvironment.VirtualPathProvider.GetFile(virtualPath).Open();
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ using Orchard.Caching;
|
||||
namespace Orchard.FileSystems.VirtualPath {
|
||||
public interface IVirtualPathProvider : IVolatileProvider {
|
||||
string Combine(params string[] paths);
|
||||
string ToAppRelative(string virtualPath);
|
||||
string MapPath(string virtualPath);
|
||||
|
||||
bool FileExists(string virtualPath);
|
||||
|
Loading…
Reference in New Issue
Block a user