File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change 1
1
using System ;
2
+ using System . Reflection ;
2
3
using System . Web . Http ;
3
4
using System . Web . Http . Dispatcher ;
4
5
using System . Web . Http . SelfHost ;
@@ -9,9 +10,13 @@ namespace ScriptCs.WebApi
9
10
public class WebApi : IScriptPackContext
10
11
{
11
12
12
- public HttpSelfHostServer CreateServer ( HttpSelfHostConfiguration config )
13
+ public HttpSelfHostServer CreateServer ( HttpSelfHostConfiguration config , Assembly caller = null )
13
14
{
14
- var caller = System . Reflection . Assembly . GetCallingAssembly ( ) ;
15
+ if ( caller == null )
16
+ {
17
+ caller = Assembly . GetCallingAssembly ( ) ;
18
+ }
19
+
15
20
config . Services . Replace ( typeof ( IHttpControllerTypeResolver ) , new ControllerResolver ( caller ) ) ;
16
21
17
22
config . Routes . MapHttpRoute ( name : "DefaultApi" ,
@@ -23,7 +28,8 @@ public HttpSelfHostServer CreateServer(HttpSelfHostConfiguration config)
23
28
24
29
public HttpSelfHostServer CreateServer ( string baseAddress )
25
30
{
26
- return CreateServer ( new HttpSelfHostConfiguration ( baseAddress ) ) ;
31
+ var caller = Assembly . GetCallingAssembly ( ) ;
32
+ return CreateServer ( new HttpSelfHostConfiguration ( baseAddress ) , caller ) ;
27
33
}
28
34
}
29
35
}
You can’t perform that action at this time.
0 commit comments