No problem, but a real functional example would be better for NH's users,
believe me.
2009/3/24 Peter Morris <[email protected]>

>
> Hi Fabio
>
> > Interesting.Do you have a public example ?
>
> I'm a complete newbie with NH so no :-)
>
> The implementation though would be something like
>
> var mainContainer = new UnityContainer();
>
> //Registration of new feature
> mainContainer.AddNewExtension<HierarchicalLifetimeExtension>();
>
> //Register repositories etc from some config, but here manually for
> illustration purposes
> mainContainer.RegisterType<ISomeBusinessProcess, SomeBusinessProcess>(new
> HierarchicalLifetimeManager());
>
>
>
> Now let's say the constructor of ISomeBusinessProcess requires an
> IUnitOfWork, which is our context.  You would do this
>
> //01: Create a child container to hold the context
> using (var childContainer = mainContainer.CreateChildContainer())
> {
>
>    //02: Register the context in the child container
>    childContainer.RegisterInstance<IUnitOfWork>(new UnitOfWork());
>
>    //03: Resolve the business process in the child container.
>    //This creates it and injects the IUnitOfWork we just created
>    var someBusinessProcess =
> childContainer.Resolve<ISomeBusinessProcess>();
>    someBusinessProcess.Execute();
> }
>
> Obviously this is a procedural example, the real thing wouldn't reference
> the containers directly etc.  But the point is that anything the
> SomeBusinessProcess requires will be injected and will also work with the
> same IUnitOfWork instance because it is all operating within the same child
> container.
>
>
> Pete
>
>
> >
>


-- 
Fabio Maulo

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to