public static class BootStrapper { public static void Bootstrap() { ObjectFactory.Initialize(x => { x.AddRegistry(new EFRepositoryRegistry()); x.AddRegistry(new ServicesRegistry()); }); DependencyResolver.SetResolver( t => { try { return ObjectFactory.GetInstance(t); } catch { return null; } }, t => ObjectFactory.GetAllInstances<object>().Where(s => s.GetType() == t) ); } }
Invoke the DI registration in the Application_Start() method in the Global.asax:
protected void Application_Start() { BootStrapper.Bootstrap(); }
No comments:
Post a Comment