using System;
namespace Wayne.Lib
{
///
/// Interface representing a service container. Dispose will dispose all disposable services.
///
public interface IServiceContainer : IServiceLocator, IDisposable
{
///
/// Register an external resolver, if you want to hook up the container against another Ioc framework for example.
///
///
void RegisterResolver(Func requestedType);
///
/// Registers service of type TService in the container. A new instance of this type will be created by the container.
///
/// Type of service.
void RegisterService();
///
/// Registers service of type TService in the container. A new instance of this type will be created by the container.
///
/// Type of service.
/// A string to identfy this entry.
void RegisterService(string serviceId);
///
/// Registers service of type TServiceContract in the container. An instance of TServiceImplementation will be created by the container and registerd as TServiceContract.
///
/// Contract that should be registered in the container, e.g. IFoo.
/// Implementation of the contract, e.g. Foo implementing IFoo.
void RegisterService()
where TServiceImplementation : TServiceContract
where TServiceContract : class;
///
/// Registers service of type TServiceContract in the container. An instance of TServiceImplementation will be created by the container and registerd as TServiceContract.
///
/// Contract that should be registered in the container, e.g. IFoo.
/// Implementation of the contract, e.g. Foo implementing IFoo.
/// A string to identfy this entry.
void RegisterService(string serviceId)
where TServiceImplementation : TServiceContract
where TServiceContract : class;
///
/// Registers service of type TServiceContract in the container. The instance that must implement this service contract is passed as an argument.
///
/// Contract that should be registerd in the container, e.g. IFoo.
/// Instance of service implementing TServiceContract, e.g. an instance of Foo where Foo implements IFoo.
void RegisterService(TServiceContract serviceInstance);
///
/// Registers service of type TServiceContract in the container. The instance that must implement this service contract is passed as an argument.
///
/// Contract that should be registerd in the container, e.g. IFoo.
/// Instance of service implementing TServiceContract, e.g. an instance of Foo where Foo implements IFoo.
/// A string to identfy this entry.
void RegisterService(TServiceContract serviceInstance, string serviceId);
///
/// Registers a service using a given a delegate that creates the service. This enables the user of this container
/// to control the creation of the service and at the same time use dependencies from the container.
/// Example using lambdas : serviceContainer.RegisterService(container => new Foo("myConstant", container.GetService<IDependency>()))
///
/// Contract that should be registerd in the container, e.g. IFoo.
/// Delegate that constructs the service.
void RegisterService(ObjectConstructor serviceConstructor);
///
/// Registers a service using a given a delegate that creates the service. This enables the user of this container
/// to control the creation of the service and at the same time use dependencies from the container.
/// Example using lambdas : serviceContainer.RegisterService(container => new Foo("myConstant", container.GetService<IDependency>()))
///
/// Contract that should be registerd in the container, e.g. IFoo.
/// Delegate that constructs the service.
/// A string to identfy this entry.
void RegisterService(ObjectConstructor serviceConstructor, string serviceId);
}
///
/// Delegate used by the service container to enable outside control of the construction of an object in the container.
///
///
///
///
///
public delegate TReturnType ObjectConstructor(TServiceLocator serviceLocator);
}