In this recipe, we will show you how you can inject services into your entities to separate implementation details from your real business logic.
Download
uNHAddIns.CommonServiceLocatorAdapters.dll
from the unofficial NHibernate AddIns project at https://bitbucket.org/fabiomaulo/unhaddinsDownload
Ninject.dll
andCommonServiceLocator.NinjectAdapter.dll
from the Ninject project at http://ninject.orgDownload
Microsoft.Practices.ServiceLocation.dll
from the Microsoft patterns and practices team and available at http://commonservicelocator.codeplex.com/
Create a new console application project named
IoCByteCode
.Add a reference to
NHibernate.dll
,Ninject.dll
,CommonServiceLocator.NinjectAdapter.dll
,uNHAddIns.CommonServiceLocatorAdapters.dll
, andMicrosoft.Practices.ServiceLocation.dll
.Add an interface named
IPasswordHasher
with the following method definition:string HashPassword...