I'm considering switching from Autofac to Simple Injector due to seemingly better decorator support. But I'm very fond of the way you register and host svc-less WCF services with Autofac and I can't find a way to do exactly that with Simpleinjector.
For instance, with Autofac it works like this (in Application_Start):
During container build:
builder.RegisterType<SomeService>().As<ISomeService>();
After the container has been constructed:
RouteTable.Routes.Add(
new ServiceRoute("", new AutofacServiceHostFactory(), typeof(ISomeService)))
Please note the empty-string routePrefix in the ServiceRoute
in order to achieve rest-style service-endpoints without an actual service-name in the url.
Is there an equivalent to this in Simple Injector?
Just use:
SimpleInjectorServiceHostFactory.SetContainer(container);
RouteTable.Routes.Add(
new ServiceRoute("",
new SimpleInjectorServiceHostFactory(),
typeof(ISomeService)));
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.