mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-07-15 14:54:57 +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, '/');
|
return Path.Combine(paths).Replace(Path.DirectorySeparatorChar, '/');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public string ToAppRelative(string virtualPath) {
|
||||||
|
return "~/" + ToFileSystemPath(virtualPath);
|
||||||
|
}
|
||||||
|
|
||||||
public string MapPath(string virtualPath) {
|
public string MapPath(string virtualPath) {
|
||||||
throw new NotImplementedException("Mapping to a physical file is not supported in Unit Test with this stub.");
|
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){
|
public override IEnumerable<string> GetFileDependencies(DependencyDescriptor dependency, string virtualPath){
|
||||||
var path1 = virtualPath.StartsWith("~") ? virtualPath : "~" + virtualPath;
|
virtualPath = _virtualPathProvider.ToAppRelative(virtualPath);
|
||||||
var path2 = dependency.VirtualPath.StartsWith("~") ? dependency.VirtualPath : "~" + dependency.VirtualPath;
|
|
||||||
|
|
||||||
if (StringComparer.OrdinalIgnoreCase.Equals(path1, path2)) {
|
if (StringComparer.OrdinalIgnoreCase.Equals(virtualPath, dependency.VirtualPath)) {
|
||||||
return GetSourceFiles(virtualPath);
|
return GetSourceFiles(virtualPath);
|
||||||
}
|
}
|
||||||
return base.GetFileDependencies(dependency, virtualPath);
|
return base.GetFileDependencies(dependency, virtualPath);
|
||||||
|
@ -17,7 +17,7 @@ namespace Orchard.FileSystems.VirtualPath {
|
|||||||
.GetDirectory(path)
|
.GetDirectory(path)
|
||||||
.Files
|
.Files
|
||||||
.OfType<VirtualFile>()
|
.OfType<VirtualFile>()
|
||||||
.Select(f => VirtualPathUtility.ToAppRelative(f.VirtualPath));
|
.Select(f => ToAppRelative(f.VirtualPath));
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<string> ListDirectories(string path) {
|
public IEnumerable<string> ListDirectories(string path) {
|
||||||
@ -26,13 +26,17 @@ namespace Orchard.FileSystems.VirtualPath {
|
|||||||
.GetDirectory(path)
|
.GetDirectory(path)
|
||||||
.Directories
|
.Directories
|
||||||
.OfType<VirtualDirectory>()
|
.OfType<VirtualDirectory>()
|
||||||
.Select(d => VirtualPathUtility.ToAppRelative(d.VirtualPath));
|
.Select(d => ToAppRelative(d.VirtualPath));
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Combine(params string[] paths) {
|
public string Combine(params string[] paths) {
|
||||||
return Path.Combine(paths).Replace(Path.DirectorySeparatorChar, '/');
|
return Path.Combine(paths).Replace(Path.DirectorySeparatorChar, '/');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public string ToAppRelative(string virtualPath) {
|
||||||
|
return VirtualPathUtility.ToAppRelative(virtualPath);
|
||||||
|
}
|
||||||
|
|
||||||
public Stream OpenFile(string virtualPath) {
|
public Stream OpenFile(string virtualPath) {
|
||||||
return HostingEnvironment.VirtualPathProvider.GetFile(virtualPath).Open();
|
return HostingEnvironment.VirtualPathProvider.GetFile(virtualPath).Open();
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ using Orchard.Caching;
|
|||||||
namespace Orchard.FileSystems.VirtualPath {
|
namespace Orchard.FileSystems.VirtualPath {
|
||||||
public interface IVirtualPathProvider : IVolatileProvider {
|
public interface IVirtualPathProvider : IVolatileProvider {
|
||||||
string Combine(params string[] paths);
|
string Combine(params string[] paths);
|
||||||
|
string ToAppRelative(string virtualPath);
|
||||||
string MapPath(string virtualPath);
|
string MapPath(string virtualPath);
|
||||||
|
|
||||||
bool FileExists(string virtualPath);
|
bool FileExists(string virtualPath);
|
||||||
|
Loading…
Reference in New Issue
Block a user