forked from ServiceStack/ServiceStack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFileSystemVirtualPathProvider.cs
More file actions
50 lines (40 loc) · 1.68 KB
/
FileSystemVirtualPathProvider.cs
File metadata and controls
50 lines (40 loc) · 1.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
using System;
using System.IO;
using ServiceStack.Text;
using ServiceStack.WebHost.Endpoints;
namespace ServiceStack.Razor.VirtualPath
{
public class FileSystemVirtualPathProvider : AbstractVirtualPathProviderBase
{
protected DirectoryInfo RootDirInfo;
protected FileSystemVirtualDirectory RootDir;
public override IVirtualDirectory RootDirectory { get { return RootDir; } }
public override String VirtualPathSeparator { get { return "/"; } }
public override string RealPathSeparator { get { return Convert.ToString(Path.DirectorySeparatorChar); } }
public FileSystemVirtualPathProvider(IAppHost appHost, String rootDirectoryPath)
: this(appHost, new DirectoryInfo(rootDirectoryPath))
{ }
public FileSystemVirtualPathProvider(IAppHost appHost, DirectoryInfo rootDirInfo)
: base(appHost)
{
if (rootDirInfo == null)
throw new ArgumentNullException("rootDirInfo");
this.RootDirInfo = rootDirInfo;
Initialize();
}
public FileSystemVirtualPathProvider(IAppHost appHost)
: base(appHost)
{
Initialize();
}
protected override sealed void Initialize()
{
if (RootDirInfo == null)
RootDirInfo = new DirectoryInfo(AppHost.Config.RazorSearchPath);
if (RootDirInfo == null || ! RootDirInfo.Exists)
throw new ApplicationException(
"RootDir '{0}' for virtual path does not exist".Fmt(RootDirInfo.FullName));
RootDir = new FileSystemVirtualDirectory(this, null, RootDirInfo);
}
}
}