One of the changes I made to NCommon in 1.1 was to provide an easy way to configure NCommon’s various services. The approach taken was inspired by MassTransit’s and Caliburn’s configuration API.

To configure NCommon you can use the static Configure class:

    1 /// <summary>

    2 /// Static configuration class that allows configuration of NCommon services.

    3 /// </summary>

    4 public static class Configure

    5 {

    6     /// <summary>

    7     /// Entry point to NCommon configuration.

    8     /// </summary>

    9     /// <param name="containerAdapter">The <see cref="IContainerAdapter"/> instance to use

   10     /// for component registration.</param>

   11     /// <returns>An instance of <see cref="INCommonConfig"/> that can be used to configure

   12     /// NCommon configuration.</returns>

   13     public static INCommonConfig Using(IContainerAdapter containerAdapter)

   14     {

   15         Guard.Against<ArgumentNullException>(containerAdapter == null,

   16                                              "Expected a non-null IContainerAdapter implementation.");

   17         return new NCommonConfig(containerAdapter);

   18     }

   19 }

The Using method of the Configure class expects an instance of IContainerAdapter . An implementation of IContainerAdapter is basically a IoC container wrapper that exposes a standard contract that NCommon can use to register components with the IoC container of your choice.

Implementations of Castle Windsor, StructureMap, NInject, Unity are already provided. The interface is simple enough to implement for other containers. Below is an example of using Configure with castle windsor:

   18 var container = new WindsorContainer();

   19 var containerAdapter = new WindsorContainerAdapter(container);

   20 NCommon.Configure.Using(containerAdapter)

   21     .ConfigureState<DefaultStateConfiguration>()

   22     .ConfigureData<NHConfiguration>(nhConfiguration => nhConfiguration

   23         .WithSessionFactory(() => nhFactory))

   24     .ConfigureUnitOfWork<DefaultUnitOfWorkConfiguration>(uowConfiguration => uowConfiguration

   25         .AutoCompleteScope()

   26         .WithDefaultIsolation(IsolationLevel.ReadCommitted));

In future posts I’ll go into details on the different configuration options of NCommon.

Posted on Monday, April 05, 2010 1:30 AM | Filed Under [ NCommon ]


Comments

Gravatar
# Hi, I configure NCommon as: <b>var adapter = new ...
Posted by uhallac
on 10/3/2010 11:30 AM
Hi,
I configure NCommon as:

var adapter = new NCommon.ContainerAdapter.CastleWindsor.WindsorContainerAdapter(Container);
NCommon.Configure.Using(adapter)
.ConfigureState[DefaultStateConfiguration]()
.ConfigureData[EFConfiguration](config => config.WithObjectContext(() => Container.Resolve[MyDB]()))
.ConfigureUnitOfWork[DefaultUnitOfWorkConfiguration](config => config.AutoCompleteScope());


I get NullReferenceException when I try to use EFRepository instance. Am I missing something in the configuration?
Thanks.

P.S. Comment removes html tags so I used '[' and ']' in the message.
Gravatar
# Hi, can u please provide the way to configure usin...
Posted by Game Play Life
on 7/9/2010 7:01 AM
Hi, can u please provide the way to configure using EF4 and unity
Gravatar
# re: Configuring NCommon in 1.1
on 9/15/2011 3:44 AM
This new and continued the Jeremy Scott usage of "tongue reconstruction method", all of the previous "Tai di bear" pattern must not a stranger to this selection of Chinese people more familiar with the pandas as a design based on without white and delicate colors easily to create a cute style, it is thanks to our national treasures born beautiful, simple black and white has enough.
Gravatar
# re: Configuring NCommon in 1.1
on 9/26/2011 6:53 AM
I actually had this on my mind a few days ago..
Gravatar
# Mens Haircuts
Posted by Mens Haircuts
on 9/27/2011 3:33 AM
once you have a great idea you have to work hard to turn it into a viable product that doesn’t just exist in your head.
Gravatar
# Hotels in Cairns
on 9/28/2011 1:18 AM
I found your blog via Google whilst looking for a related topic, your website came up, it looks good. Ive bookmarked it in my google bookmarks.thanx alot
Gravatar
# hotels in Kingston
on 9/29/2011 1:56 AM
I like this post,And I guess that they having fun to read this post,they shall take a good site to make a information,thanks for sharing it to me.
Gravatar
# innsbruck hotels
on 9/30/2011 3:41 AM
Very nice blog! It really made me interested here. Thank you for bringing more informative post. I can't wait to read more of your blogs thanx alot
Gravatar
# hotels in warwick
on 10/1/2011 6:20 AM
there is a saying that says good things come to those who wait ! Personally, I think that finding such a great blog stands for efforts. What I like the most about the site is the fact that comedy is taken seriously.
Gravatar
# Hotels in Marseille
on 10/3/2011 1:31 AM
I love your site, big thank you to these ideas, and note in the first place that I fully agree with you! Let me emphasize, yes your blog was excellent, I was thinking about all this and more the other day. This is my very first comment here and I'll come back with pleasure on this blog!
Gravatar
# protonix
Posted by protonix
on 10/6/2011 1:46 AM
Your blog is a great one. What really impresses me is that you are correctly mentioned that there are thousands of tools that are available to create a website or launch one but what matters is that you choose the right one, the one that gives you all that is actually needed Well good to read about this thanks. Awesome...It's nice share that, thanks very much!
Gravatar
# prescription savings
on 10/6/2011 11:23 PM
great and full of various and attractive information about everything. Thanks a lot one more time for the great and informative blog and keep up publishing these great posts in the future.
Gravatar
# Grand Theft Auto V
on 11/14/2011 3:47 AM
Thanks so very much for taking your time to create this very useful and informative site. I have learned a lot from your site. Thanks guys
Grand Theft Auto V
Gravatar
# protonix
Posted by protonix
on 11/15/2011 11:33 PM
I am really impressed by this excellent stuff. I always prefer to read the quality content and this thing I found in you post. Thanks for sharing.
Gravatar
# prescription coupons
on 11/16/2011 2:37 AM
wow,
this was really cool, this is one amazing article! Thank you for posting this.
Gravatar
# Hormone Replacement For Men
on 11/16/2011 6:40 AM
This article is very useful. Thanks so much for sharing. I can be very good reader & listener if you are searching for. Appreciate for your time!
Gravatar
# alexandria hotels
on 11/17/2011 5:13 AM
Keep up the great job and you will surely attract more readers. Love your post, very simple & informative.
Gravatar
# amman hotels
Posted by amman hotels
on 11/18/2011 1:13 AM
The look of this blog is very attractive and outstanding,i really liked it and appreciate this amazing work of art in this blog.
Gravatar
# antalya hotels
Posted by antalya hotels
on 11/18/2011 6:34 AM
Useful information ..I am very happy to read this article..thanks for giving us this useful information. Fantastic walk-through. I appreciate this post.
Gravatar
# article submission service
on 11/21/2011 4:14 AM
Really your post is really very good and I appreciate it. It’s hard to sort the good from the bad sometimes, but I think you’ve nailed it. You write very well which is amazing. I really impressed by your post.
Gravatar
# blog commenting service
on 11/21/2011 11:50 PM
Great post. i like it. feeling great when reading your post. The content of the articles there will be a lot of attractive people to appreciate
Gravatar
# Content Writing Services
on 11/22/2011 2:52 AM
I want to thank you for this informative read; I really appreciate sharing this great.Thanks..!!
Gravatar
# directory submission service
on 11/22/2011 6:01 AM
It is a very informative and useful post… Thank you it is good material to read this post increases my knowledge.
Gravatar
# auckland hotels
Posted by auckland hotels
on 11/23/2011 4:13 AM
After reading you site, Your site is very useful for me .I bookmarked your site!
Gravatar
# bradford hotels
Posted by bradford hotels
on 11/23/2011 11:32 PM
It's my first time visit here. And I found so many entertaining stuff in this blog, especially its discussion.
Gravatar
# kitchens
Posted by kitchens
on 11/24/2011 1:55 AM
This is a great article. I am pretty much pleased with your good work. You put really very helpful information. Keep it up.
Gravatar
# pr agency manchester
on 11/24/2011 5:26 AM
I like this concept. I visited your blog for the first time. Keep posting as I am gonna come to read it everyday!!
Gravatar
# canberra hotels
Posted by canberra hotels
on 11/25/2011 1:16 AM
I havent any word to appreciate this post…..Really i am impressed from this post….the person who create this post it was a great human..thanks for shared this with us.
Gravatar
# casablanca hotels
on 11/25/2011 4:40 AM
Nice post. This is a great blog and I have to congratulate you on the content.
Gravatar
# cincinnati hotels
on 11/25/2011 11:44 PM
Great site, thank you for sharing, I thought all in one day!.. really nice. You have a beautiful pen, hats off to you.
Gravatar
# colombo hotels
Posted by colombo hotels
on 11/26/2011 1:50 AM
I like the style of blogger to show this blog. I liked this blog because it is shown in a good manner. and here are many informational thing which is very good to have.thanks for this nice one !!!
Gravatar
# faro hotels
Posted by faro hotels
on 11/26/2011 4:29 AM
That Post is Full of informative. Thanks for that kind of sharing. Hope u will again share with us.
Gravatar
# halifax hotels
Posted by halifax hotels
on 11/28/2011 12:05 AM
Here is good subject taken by the writter and i can say that he has good knowledge about this.Hope you will provide more information
Gravatar
# motorcycle Riding Gear
on 11/28/2011 2:22 AM
I always like to read article posted by this site.This content is to intrested
Gravatar
# wrist watches
Posted by wrist watches
on 11/28/2011 5:06 AM
I love your blog so much, and there are just some differences with others’. Hope there will be more wonderful things in your blog.thanks a lot.
Gravatar
# Ladies Handbags
Posted by Ladies Handbags
on 11/29/2011 1:35 AM
I am glad to found such useful post. I really increased my knowledge after read your post which will be beneficial for me.
Gravatar
# motorcycle clothes
on 11/29/2011 3:11 AM
I really loved reading your blog. It was very well authored and easy to undertand. Unlike additional blogs I have read which are really not tht good. I also found your posts very interesting.
Gravatar
# motorbike gear
Posted by motorbike gear
on 11/29/2011 5:40 AM
I am always on the lookout for quality posts and articles so i suppose im lucky to have found this! I hope you will be adding more in the future…
Gravatar
# leather clothing
on 11/30/2011 4:22 AM
Hello I just wanted to leave a comment to say that I enjoy your blog. Looking at the number of comments, I see others feel the same way!
Gravatar
# leather clothing
on 11/30/2011 6:15 AM
Superb! Generally I never read whole articles but the way you wrote this information is simply amazing and this kept my interest in reading and I enjoyed it.
Gravatar
# leather shop
Posted by leather shop
on 12/1/2011 12:07 AM
Thank you for bringing more information to this topic for me. Im truly grateful and really impressed.
Gravatar
# leather Fashion
Posted by leather Fashion
on 12/1/2011 2:04 AM
Very nice site! Lots and lots of good information here! Not many questions left unanswered! Thank you so much for the share!
Gravatar
# fashion jewelry
Posted by fashion jewelry
on 12/2/2011 6:58 AM
This is nice post which I was awaiting for such an article and I have gained some very handy information from this site, I admire the valuable information you offer in all your articles
Gravatar
# vacation packages
on 12/3/2011 12:46 AM
Hi, I read a few of your other posts and i wanted to say thank you for the informative posts..
Gravatar
# cheap sunglasses
on 12/3/2011 2:35 AM
So informative things are provided here, I really happy to read this post, I was just imagine about it and you provided me the correct information I really bookmark it, for further reading, So thanks for sharing the information.
Gravatar
# hotels in victoria
on 12/3/2011 5:17 AM
This is the first time i am reading your post and admire that you posted article which gives users lot of information regarding particular topic. Thanks for this share.
Gravatar
# hotels in valencia
on 12/3/2011 6:43 AM
This blog contains a lot of informative data and news which i first time read from here. Thanks for writing about this important topic.
Gravatar
# hotels in luxor
Posted by hotels in luxor
on 12/7/2011 1:08 AM
Nice information, many thanks to the author. It is incomprehensible to me now, but in general, the usefulness and significance is overwhelming. Thanks again and good luck..
Gravatar
# hotels in longbeach
on 12/7/2011 4:44 AM
Thanks for taking the time to discuss this, I feel strongly about it and love learning more on this topic. If possible, as you gain expertise, would you mind updating your blog with extra information? It is extremely useful for me.
Gravatar
# hotels in kiev
Posted by hotels in kiev
on 12/7/2011 6:20 AM
This is a great post. I like this topic.This site has lots of advantage. I found many interesting things from this site. It helps me many away..So i want some information for sharing this side..
Gravatar
# cheap SEO Services
on 12/8/2011 2:19 AM
I would like to thank you for the efforts you have made in writing this post
Gravatar
# Birthday Parties
on 12/8/2011 2:44 AM
Really appreciate this wonderful post that you have provided for us.Great site and a great topic as well i really get amazed to read this
Gravatar
# Hormone Replacement Therapy
on 12/8/2011 4:52 AM
I was very encouraged to find this site. I wanted to thank you for this special read. I definitely savored every little bit of it and I have you bookmarked to check out new stuff you post..
Gravatar
# heated motorcycle clothing
on 12/8/2011 6:39 AM
This is so cool. I am such a huge fan of their work. I really am impressed with how much you have worked to make this website so enjoyable.
Gravatar
# leather motorcycle jackets for men
on 12/9/2011 12:42 AM
That's very attractive and awesome I got to read about, I was just passing by to your site and got the stuff here very informative. Nice site.
Gravatar
# motorbike jacket
on 12/9/2011 2:22 AM
That's very awesome and amazing I got to read about, I was just passing by to your site and got the stuff here very informative. Awesome blog and website!
Gravatar
# leather biker jackets
on 12/12/2011 12:58 AM
I am very enjoyed for this side. Its a nice topic. It help me very much to solve some problems. Its opportunity are so fantastic and working style so speedy. I think it may be help all of you. Thanks..
Gravatar
# biker leather jacket
on 12/12/2011 5:05 AM
This is really useful and interesting information for me. I like your blog design. It is easy to navigate, clean, uncluttered and the colours are very harmonious. .
Gravatar
# personal care
Posted by personal care
on 1/2/2012 4:41 AM
That's just so generous of you that you have provided us with this kind of worthy information.
Gravatar
# Lifetime Guarantee Pipes
on 1/9/2012 9:21 AM
I have not been able to find such kind of information throughout the search engines and internet. It's been fabelously informative to read your blog and i am going to suggest it to another fellow as well.
Gravatar
# home remedies for acne
on 1/28/2012 11:51 AM
I have not been able to find such kind of information throughout the search engines and internet.
Gravatar
# re: Configuring NCommon in 1.1
on 2/11/2012 12:55 AM
Thank you for this great information, you write very well which i like very much. I am really impressed by your post.
Gravatar
# re: Configuring NCommon in 1.1
on 2/14/2012 3:56 AM
I appreciate for your post! I hope you will keep it on. I also want to make friends with you and share my favorite replica .thank you.
Gravatar
# re: Configuring NCommon in 1.1
on 2/28/2012 5:02 PM
Great info here on the site. This must have taken a long time to come up with.
Gravatar
# Tax Attorney
Posted by Tax attorney
on 3/3/2012 9:13 AM
Awesome help with the code. Will bookmark this.
Gravatar
# hayao miyazaki collection
on 3/8/2012 8:34 PM


Wow, Your article is really good,give me a new view,Your blog is great and interesting!
http://www.collectcheaps.com/
Gravatar
# value of annuity
on 3/9/2012 4:25 AM
Thanks for sharing! I agree with you. The artical improve me so much! I will come here frequently.
Gravatar
# ptc
Posted by ptc
on 3/17/2012 11:06 PM


I am new to the blog. Hope I will get new tips & ideas from this blog…!!!
Gravatar
# buy blog comments
on 4/23/2012 2:52 AM
Nice post. I like the way you start and then conclude your thoughts. Thanks for this information .I really appreciate your work, keep it up and thanks for sharing information with me.
Post Comment
Title *
Name *
Email
Url
Comment *  
Please add 6 and 3 and type the answer here: