Skip to content

Common Service Registry

Common Service Registry
Based on my previous blog post Decouple IoC/DI container when authoring a C# library I have written some C# Nuget packages to have that Service Registry thing easily available in all my C# projects. The package(s) are called “Common Service Registry” (see here).

Packages

Currently the Common Service Registry (CSR) contains three packages. You mainly need two of them. The one always needed is the CommonServiceRegistry.Core. It contains the basic interfaces like ICommonServiceRegistry against which one needs to register its DI needs.

To finally use the Common Service Registry one also needs an adapter package that build the bridge between the concrete IoC product you are using and the Common Service Registry.

The following two adapters are currently available:

  • CommonServiceRegistry.SimpleInjector for using CSR with Simple Injector (my favorite)
  • CommonServiceRegistry.Unity for using CSR with Unity

So you need the Core package and one of the above adapter. If you need an additional adapter please create an issue over on GitBub.

How to use

Check out the how to use over at GitHub. Its really easy to use that thing. The application needs one additional line and the library needs no additional lines of code (comparing to register without Common Service Registry).

Writing an adapter

A new adapter can be implemented with minimal effort. See the source-code of the other adapters (eg. this one). Note that each adapter also should have its unit-test assembly and that there is a base-class for adapter tests. So writing unit-tests for new adapters is done with a few lines of code as you can see here.

Contribute!

Contributions are very welcome. If you like to check out (or fork) the source-code you’ll find it on here GitHub. You can have a look at the issues and pick one to work on.

marcd View All

I love to write software. More then two decades ago I managed to make my hobby my full-time job so I spent more then 20 year writing professional software (I guess that makes me a "Senior Software Developer"). The last few years I spend most of the time developing in C#/.Net for all kind of windows-, web- and embedded-software.

In my free time I enjoy my family, taking photos and go diving in cold lakes and rivers in Switzerland.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: