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
10/19/2010 12:03:01 PM #
I m no expert, but I believe you just made an excellent point. You certainly fully understand what your speaking about, and I can truly get behind that. Thanks for staying so upfront and so sincere.
10/19/2010 12:19:42 PM #
I just found this blog and have high hopes for it to continue. Keep up the great work, its hard to find good ones. I have added to my favorites. Thank You.
10/19/2010 12:39:26 PM #
It was a very nice idea! Just wanna say thank you for the information you have shared. Just continue writing this kind of post. I will be your loyal reader. Thanks again
11/4/2010 4:41:33 AM #
Great Blog! Will visit again
11/4/2010 4:43:05 AM #
Thank you for the information, keep up the good work
11/4/2010 4:44:47 AM #
Excellent post, thanks.
11/4/2010 4:45:24 AM #
Just the information I was looking for, thank you
11/4/2010 4:46:51 AM #
Very interesting, will visit again
11/4/2010 4:47:43 AM #
That was very informative. Thank you for sharing. Smile
11/20/2010 4:01:57 AM #
Hello People! Your blog is awesome! I would like to visit it everyday. It's very informative and amazing
12/15/2010 10:38:14 AM #
Great Blog! Will visit again
12/15/2010 10:38:58 AM #
Thank you for the information, keep up the good work
12/15/2010 10:40:04 AM #
Excellent post, thanks.
12/15/2010 10:40:50 AM #
Just the information I was looking for, thank you
12/15/2010 10:41:49 AM #
Very interesting, will visit again
12/15/2010 10:42:41 AM #
That was very informative. Thank you for sharing. Smile
12/26/2010 4:46:29 PM #
I was searching for this post, and finally got this blog, really very informative one.
1/1/2011 11:16:35 AM #
Nice one! Going to apply this one and I think will have a good result.
1/3/2011 2:49:36 PM #
Thanks for the code on how this is done correctly.
1/8/2011 8:49:34 AM #
Your blog is really excellent
1/10/2011 4:04:25 AM #
love the psot and what you've explained!
3/21/2011 10:52:20 PM #
I just want to say that your blog is very nice.  Please keep writing informative articles like this.
3/22/2011 7:40:03 PM #
Make sure you dismiss all the terrible and also uselss opinions. Thank you to the writer for fantastic facts!
3/23/2011 11:30:43 AM #
Hello to all Smile I can’t understand how to add your site in my rss reader. Help me, please
3/23/2011 2:57:48 PM #
thanks !!  very helpful post!
Comments are closed