forked from ServiceStack/ServiceStack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathResourceVirtualPathProvider.cs
More file actions
54 lines (45 loc) · 1.81 KB
/
ResourceVirtualPathProvider.cs
File metadata and controls
54 lines (45 loc) · 1.81 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
51
52
53
54
using System;
using System.Reflection;
using ServiceStack.VirtualPath;
using ServiceStack.WebHost.Endpoints;
namespace ServiceStack.Plugins.Embedded.VirtualPath
{
public class ResourceVirtualPathProvider : AbstractVirtualPathProviderBase
{
protected ResourceVirtualDirectory RootDir;
protected Assembly BackingAssembly;
public override IVirtualDirectory RootDirectory { get { return RootDir; } }
public override string VirtualPathSeparator { get { return "/"; } }
public override string RealPathSeparator { get { return "."; } }
public ResourceVirtualPathProvider(IAppHost appHost, Type typeInBackingAssembly)
: base(appHost)
{
if (typeInBackingAssembly == null)
throw new ArgumentNullException("typeInBackingAssembly");
this.BackingAssembly = typeInBackingAssembly.Assembly;
Initialize();
}
public ResourceVirtualPathProvider(IAppHost appHost, Assembly backingAssembly)
: base(appHost)
{
if (backingAssembly == null)
throw new ArgumentNullException("backingAssembly");
this.BackingAssembly = backingAssembly;
Initialize();
}
public ResourceVirtualPathProvider(IAppHost appHost)
: base(appHost)
{
Initialize();
}
protected override sealed void Initialize()
{
var asm = BackingAssembly ?? AppHost.GetType().Assembly;
RootDir = new ResourceVirtualDirectory(this, null, asm);
}
public override string CombineVirtualPath(string basePath, string relativePath)
{
return string.Concat(basePath, VirtualPathSeparator, relativePath);
}
}
}