Sunday, 25 August 2013

IoC Generic Container Interface

A generic interface that can be implemented for different IoC containers. By using the interface switching between container implementations would be easy, particularly helpfull when testing the use of a container.

using System;
using System.Collections.Generic;

namespace IoC
public interface IIoCGenericContainer
object Resolve(Type t);

T Resolve<T>();

T TryResolve<T>();

IEnumerable<object> ResolveAll(Type t);

IEnumerable<T> ResolveAll<T>();

void RegisterType<T>();

void RegisterType<T>(bool singleton);

void RegisterType<TFrom, TTo>() where TTo : TFrom;

void RegisterType<TFrom, TTo>(bool singleton) where TTo : TFrom;

void RegisterInstance(object instance);

void RegisterInstance<TInterface>(TInterface instance);

void RegisterInstance<TInterface>(TInterface instance, bool singleton);

No comments:

Post a Comment