In this recipe, I'll show you how we can inject services into our entities to separate implementation details from our real business logic.
Download uNHAddIns.CommonServiceLocatorAdapters.dll
from the Unofficial NHibernate AddIns project at http://code.google.com/p/unhaddins/.
Download Ninject.dll
and CommonServiceLocator.NinjectAdapter.dll
from the Ninject project at http://ninject.org.
Download Microsoft.Practices.ServiceLocation.dll
from the Microsoft Patterns and Practices team available at http://commonservicelocator.codeplex.com/.
Put these three assemblies in your solution's Lib
folder.
Create a new console application project named
IoCByteCode
.Add a reference to
NHibernate.dll
,NHibernate.ByteCode.Castle.dll
,Ninject.dll
,CommonServiceLocator.NinjectAdapter.dll
,uNHAddIns.CommonServiceLocatorAdapters.dll
, andMicrosoft.Practices.ServiceLocation.dll
.Add an interface named
IPasswordHasher
with the following method definition...