Hi all,

I have a requirement where my object needs a dependancy to a service. In
this case I want to gritter a notification message.

There are some design solutions:
 * notify via an event
 * inject a dependancy during a load from the database
 * Use a unit of work to publish a notification message


Here are some examples.


== Notify via an event ==

class MyEntity
{
    public static event Reset ...;

    public static OnReset()
    {
         if(Reset!=null) Reset(this, null);
    }
}

MyEntity.Reset += ()=> Bus.Publish(new ResetMessage());

var entity = Session.Get<MyEntity>();
entity.Reset();


== Inject dependancy to publish event ==

class MyEntity
{
    public IBus Bus { get; set; }

    public void Reset()
    {
          Bus.Publish(new ResetMessage());
    }
}


== Use a unit of work to publish a notification message ==

var entity = Session.Get<MyEntity>();
entity.Reset();
Bus.Publish(new ResetMessage());




Does anybody have any experience with one of these solutions? I am
especially interested in if the second example (inject a dependancy during a
load/get from the database) is possible with NHiberate. I think it is
because it can use Castle Windsor but I do not know how I can pass the
container that contains the dependancies.



-- 
Ramon

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