dependency injection - Convert Ninject DI to Unity DI -
how convert following ninject di unity? i'm having trouble understanding correct syntax.
/// <summary> /// load modules or register services here! /// </summary> /// <param name="kernel">the kernel.</param> private static void registerservices(ikernel kernel) { database.setinitializer(new migratedatabasetolatestversion<defaultmembershiprebootdatabase, brockallen.membershipreboot.ef.migrations.configuration>()); var config = membershiprebootconfig.create(); kernel.bind<membershiprebootconfiguration>().toconstant(config); kernel.bind<useraccountservice>().toself(); kernel.bind<authenticationservice>().to<samauthenticationservice>(); kernel.bind<iuseraccountquery>().to<defaultuseraccountrepository>().inrequestscope(); kernel.bind<iuseraccountrepository>().to<defaultuseraccountrepository>().inrequestscope(); }
- registering single instance done using
registerinstance
method. - registering types 'self' done using
registertype<t>()
method. - registering types request lifestyle done using
hierarchicallifetimemanager
.
Comments
Post a Comment