C# Class LinFu.IoC.ServiceContainer

Represents a service container with additional extension points for customizing service instances
Inheritance: IServiceContainer
Mostrar archivo Open project: philiplaureano/LinFu Class Usage Examples

Private Properties

Property Type Description

Public Methods

Method Description
AddFactory ( Type serviceType, IEnumerable additionalParameterTypes, IFactory factory ) : void

Adds an IFactory instance and associates it with the given service type.

AddFactory ( string serviceName, Type serviceType, IEnumerable additionalParameterTypes, IFactory factory ) : void

Adds an IFactory instance and associates it with the given service type and service name.

Contains ( Type serviceType, IEnumerable additionalParameterTypes ) : bool

Determines whether or not the given serviceType can be instantiated by the container.

Contains ( string serviceName, Type serviceType, IEnumerable additionalParameterTypes ) : bool

Determines whether or not a service can be created using the given service name and service type.

GetService ( Type serviceType ) : object

Overridden. Causes the container to instantiate the service with the given service type. If the service type cannot be created, then an exception will be thrown if the IContainer.SuppressErrors property is set to false. Otherwise, it will simply return null.

This overload of the GetService method has been overridden so that its results can be handled by the postprocessors.

GetService ( string serviceName, Type serviceType ) : object

Causes the container to instantiate the service with the given service type. If the service type cannot be created, then an exception will be thrown if the IContainer.SuppressErrors property is set to false. Otherwise, it will simply return null.

ServiceContainer ( ) : System

Initializes the container with the default services.

ServiceContainer ( IGetService getServiceBehavior, IFactoryStorage factoryStorage ) : System

Initializes the container with a custom ICreateInstance type.

Method Details

AddFactory() public method

Adds an IFactory instance and associates it with the given service type.
public AddFactory ( Type serviceType, IEnumerable additionalParameterTypes, IFactory factory ) : void
serviceType System.Type The service type to associate with the factory
additionalParameterTypes IEnumerable The list of additional parameters that this factory type will support.
factory IFactory The instance that will be responsible for creating the service instance
return void

AddFactory() public method

Adds an IFactory instance and associates it with the given service type and service name.
public AddFactory ( string serviceName, Type serviceType, IEnumerable additionalParameterTypes, IFactory factory ) : void
serviceName string The name of the service to associate with the given instance.
serviceType System.Type The type of service that the factory will be able to create.
additionalParameterTypes IEnumerable The list of additional parameters that this factory type will support.
factory IFactory The instance that will create the object instance.
return void

Contains() public method

Determines whether or not the given serviceType can be instantiated by the container.
public Contains ( Type serviceType, IEnumerable additionalParameterTypes ) : bool
serviceType System.Type The type of service to instantiate.
additionalParameterTypes IEnumerable The list of additional parameters that this factory type will support.
return bool

Contains() public method

Determines whether or not a service can be created using the given service name and service type.
public Contains ( string serviceName, Type serviceType, IEnumerable additionalParameterTypes ) : bool
serviceName string The name of the service to associate with the given instance.
serviceType System.Type The type of service that the factory will be able to create.
additionalParameterTypes IEnumerable The list of additional parameters that this factory type will support.
return bool

GetService() public method

Overridden. Causes the container to instantiate the service with the given service type. If the service type cannot be created, then an exception will be thrown if the IContainer.SuppressErrors property is set to false. Otherwise, it will simply return null.
This overload of the GetService method has been overridden so that its results can be handled by the postprocessors.
public GetService ( Type serviceType ) : object
serviceType System.Type The service type to instantiate.
return object

GetService() public method

Causes the container to instantiate the service with the given service type. If the service type cannot be created, then an exception will be thrown if the IContainer.SuppressErrors property is set to false. Otherwise, it will simply return null.
public GetService ( string serviceName, Type serviceType ) : object
serviceName string The name of the service to instantiate.
serviceType System.Type The service type to instantiate.
return object

ServiceContainer() public method

Initializes the container with the default services.
public ServiceContainer ( ) : System
return System

ServiceContainer() public method

Initializes the container with a custom ICreateInstance type.
public ServiceContainer ( IGetService getServiceBehavior, IFactoryStorage factoryStorage ) : System
getServiceBehavior IGetService The instance that will be responsible for generating service instances.
factoryStorage IFactoryStorage The instance responsible for determining which factory instance will instantiate a given service request.
return System