Skip to content

Commit b557b62

Browse files
committed
Adding grabbing the caller for the overload and fixing my stupid bug
1 parent b751cb9 commit b557b62

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/ScriptCs.WebApi/WebApi.cs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.Reflection;
23
using System.Web.Http;
34
using System.Web.Http.Dispatcher;
45
using System.Web.Http.SelfHost;
@@ -9,9 +10,13 @@ namespace ScriptCs.WebApi
910
public class WebApi : IScriptPackContext
1011
{
1112

12-
public HttpSelfHostServer CreateServer(HttpSelfHostConfiguration config)
13+
public HttpSelfHostServer CreateServer(HttpSelfHostConfiguration config, Assembly caller = null)
1314
{
14-
var caller = System.Reflection.Assembly.GetCallingAssembly();
15+
if (caller == null)
16+
{
17+
caller = Assembly.GetCallingAssembly();
18+
}
19+
1520
config.Services.Replace(typeof(IHttpControllerTypeResolver), new ControllerResolver(caller));
1621

1722
config.Routes.MapHttpRoute(name: "DefaultApi",
@@ -23,7 +28,8 @@ public HttpSelfHostServer CreateServer(HttpSelfHostConfiguration config)
2328

2429
public HttpSelfHostServer CreateServer(string baseAddress)
2530
{
26-
return CreateServer(new HttpSelfHostConfiguration(baseAddress));
31+
var caller = Assembly.GetCallingAssembly();
32+
return CreateServer(new HttpSelfHostConfiguration(baseAddress), caller);
2733
}
2834
}
2935
}

0 commit comments

Comments
 (0)