Skip to content

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.

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 )

Facebook photo

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

Connecting to %s

%d bloggers like this: