This project is read-only.

Consuming the Interfaces

Se also API Reference.

Consuming the Service Location interface

This is mostly the same interface as compared to the CSL predecessor with one small update. This version of the interface takes advantage of named and optional arguments capabilities of Visual C# 2010. Basically you have the option to get one instance of a service or all registered instances.

Also I have killed the static class ServiceLocator with the static hook ServiceLocator.Current. => Q & A.

Consuming the Service Configuration interfaces

The configuration interface has been designed with as much focus on the end user as possible - the developer. The interface is supposed to be easy to understand and use. It is also easy to extend should you have such desires and needs.

  • Easy to use means it has an intuitive method chaining approach known as a fluent interface. The code resulting from usage is quite readable in almost plain English.
  • Easy to extend means that you can add your own methods to the chain of available configuration options. But you should only do that if you are quite clear that you want to divert from the ability to exchange containers at a later time. Extending is easily done by downloading the latest source code. Alternatively you can use an extension method from your own code.

The API Reference has a bit more information on the actual adaptation of these interfaces in your code.

What do I need to do exactly?

For your IoC conatiner API implement the three interfaces:

  • IServiceLocator
  • IServiceConfigurator
  • IConfigurator<TImplementation>

But wait there’s more! ;~) You might object that the IConfigurator<TImplementation> interface in the CSM uses System.Linq.Expression parameters that I have to parse in my own adapter! The reason for using the expressions is to ensure type safety in the configuration code. Should you change the implementation of the types you are configuring your configuration code will not compile! Plus this problem is already solved once:

Using the base class implementation of IConfigurator<TImplementation>

Isn’t it great that the CSM includes a base class implementation that parses the expressions and adapts to simpler methods that uses types and strings? The base class is the ConfiguratorBase<TImplementation>.

Last edited Sep 2, 2010 at 4:02 PM by noopman, version 5


No comments yet.