Home >

Making Transient as Default Lifestyle in Castle Windsor

6. August 2009

This is actually an answer to fellow blogger Jak Charlton, but I see a benefit in sharing it.

Casey pointed out that the default lifestyle should be transient. Even though I understand his reasonings, I am used to this way.

There is a solution for those who wants Transient as the default.

You know what? Yes, the events ! Here is how.

container.Kernel.ComponentModelCreated += new ComponentModelDelegate(Kernel_ComponentModelCreated);


void Kernel_ComponentModelCreated(Castle.Core.ComponentModel model)
{
	if (model.LifestyleType == LifestyleType.Undefined)
		model.LifestyleType = LifestyleType.Transient;
}

, ,

Comments

8/7/2009 4:15:20 AM #
oh cool, hadn't thought of that. excellent tip! be sure to tweet a link to this... oh wait, I guess you cant right now. hehe.
8/7/2009 4:27:32 AM #
Yeah, but it is alive again!

It has already been fetched by twitterfeed, i think you've missed it! Smile

Add comment


(Will show your Gravatar icon)

  Country flag

biuquote
  • Comment
  • Preview
Loading