i wouldn't inject services via DI. if you need to pass in a service that's 
something else.
for example I wouldn't do this

//avoid at all costs
class Entity
{
    public Entity(Idependency)
    {
    }

    public void Reset()
    {
        dependency.DoSomething();  
    }
}

//this would be more appropriate
class Entity
{
    public void Reset(Idependency dependency)
    {
        dependency.DoSomething();  
    }
}

if you want to tie into the unit of work, then you are looking at NH 
IEventListener implementations or a session interceptor. the event listener 
model is much more flexible. this works for cross cutting concerns like 
logging, auditing, validation, etc. But this approach doesn't make much 
sense in the context you describe.

That leaves domain events.
class Entity
{
    public void Reset()
    {
        //yes, this is a static gateway object.
        DomainEvents.Fire(new EntityReset(this));
    }
}

class SendMessageAfterEntityIsResent
{
      public SendMessageAfterEntityIsResent(IBus bus)
      {
      }

      public void Handel(EntityReset message)
      {
           bus.Send(new Message());
      }
}

//a very simple implementation
static class DomainEvents
{
    public void Fire<T>(T message)
    {
        container.ResolveAll<T>().Each(handler => handler.Handel(message));
    }
}
here are some more links on the subject of domain events
http://www.udidahan.com/2009/06/14/domain-events-salvation/
http://www.udidahan.com/2008/08/25/domain-events-take-2/
http://codebetter.com/gregyoung/2010/04/11/what-is-a-domain-event/

this should be enough to get you think'n :)

-- 
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