asp.net mvc - How do I use autofac to resolve a WCF Data Service? -
i creating wcf data service using wcf data services toolkit , whitepaper building odata services on top of existing apis. service being added existing mvc 3 website configured use autofacdependencyresolver. code provided in whitepaper exposing service is:
protected void application_start() { var factory = new dataservicehostfactory(); var serviceroute = new serviceroute("odata", factory, typeof(crmodataservice)); serviceroute.defaults = new routevaluedictionary { { "servicetype", "odata" } }; serviceroute.constraints = new routevaluedictionary { { "servicetype", "odata" } }; routetable.routes.add("odata", serviceroute); ... }
is there simple way modify resolve service via autofac or need implement own servicehostfactory?
i think figured out:
protected void application_start() { var factory = new autofacwebservicehostfactory(); var serviceroute = new serviceroute("odata", factory, typeof(crmodataservice)); serviceroute.defaults = new routevaluedictionary { { "servicetype", "odata" } }; serviceroute.constraints = new routevaluedictionary { { "servicetype", "odata" } }; routetable.routes.add("odata", serviceroute); ... }
and elsewhere don't forget set
autofacwebservicehostfactory.container = container;
Comments
Post a Comment