-
Notifications
You must be signed in to change notification settings - Fork 15
NHibernate.DependencyInjection
ranzlee edited this page Apr 9, 2013
·
18 revisions
Register the bytecode provider with NHibernate
Initializer.RegisterBytecodeProvider(new EntityInjector());
Implement a IEntityInjector. Anytime NHibernate needs to create an entity (or proxy), a call to GetConstructorParameters is made. Evaluate the type and return the constructor arguments, or null for a parameterless constructor.
public class EntityInjector : IEntityInjector
{
public object[] GetConstructorParameters(System.Type type)
{
if (type == typeof(DependencyInjectionCat)) return new object[] {new CatDependency()};
return null;
}
}