PageRenderTime 138ms CodeModel.GetById 134ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/src/LinFu.IoC.Common/IServiceContainer.cs

http://github.com/philiplaureano/LinFu
C# | 63 lines | 14 code | 5 blank | 44 comment | 0 complexity | bc6ec4505b93dbf4aff4e015d5eb8da2 MD5 | raw file
 1using System;
 2using System.Collections.Generic;
 3
 4namespace LinFu.IoC.Interfaces
 5{
 6    /// <summary>
 7    ///     An inversion of control container that supports
 8    ///     named services.
 9    /// </summary>
10    /// <seealso name="IContainer" />
11    public interface IServiceContainer : IContainer
12    {
13        /// <summary>
14        ///     The list of preprocessors that will handle
15        ///     every service request before each actual service is created.
16        /// </summary>
17        IList<IPreProcessor> PreProcessors { get; }
18
19        /// <summary>
20        ///     The list of postprocessors that will handle every
21        ///     service request result.
22        /// </summary>
23        IList<IPostProcessor> PostProcessors { get; }
24
25        /// <summary>
26        ///     Adds an <see cref="IFactory" /> instance and associates it
27        ///     with the given <paramref name="serviceType">service type</paramref> and
28        ///     <paramref name="serviceName">service name</paramref>.
29        /// </summary>
30        /// <param name="serviceName">The name of the service to associate with the given <see cref="IFactory" /> instance.</param>
31        /// <param name="serviceType">The type of service that the factory will be able to create.</param>
32        /// <param name="additionalParameterTypes">The list of additional parameters that this factory type will support.</param>
33        /// <param name="factory">The <see cref="IFactory" /> instance that will create the object instance.</param>
34        void AddFactory(string serviceName, Type serviceType, IEnumerable<Type> additionalParameterTypes,
35            IFactory factory);
36
37        /// <summary>
38        ///     Determines whether or not a service can be created using
39        ///     the given <paramref name="serviceName">service name</paramref>
40        ///     and <paramref name="serviceType">service type</paramref>.
41        /// </summary>
42        /// <param name="serviceName">The name of the service to associate with the given <see cref="IFactory" /> instance.</param>
43        /// <param name="serviceType">The type of service that the factory will be able to create.</param>
44        /// <param name="additionalParameterTypes">The list of additional parameters that the factory type must support.</param>
45        /// <returns>Returns <c>true</c> if the service exists; otherwise, it will return <c>false</c>.</returns>
46        bool Contains(string serviceName, Type serviceType, IEnumerable<Type> additionalParameterTypes);
47
48        /// <summary>
49        ///     Causes the container to instantiate the service with the given
50        ///     <paramref name="serviceType">service type</paramref>. If the service type cannot be created, then an
51        ///     exception will be thrown if the <see cref="IContainer.SuppressErrors" /> property
52        ///     is set to false. Otherwise, it will simply return null.
53        /// </summary>
54        /// <param name="serviceName">The name of the service to instantiate.</param>
55        /// <param name="serviceType">The service type to instantiate.</param>
56        /// <param name="additionalArguments">The additional arguments that will be used to instantiate the service type.</param>
57        /// <returns>
58        ///     If successful, it will return a service instance that is compatible with the given type;
59        ///     otherwise, it will just return a <c>null</c> value.
60        /// </returns>
61        object GetService(string serviceName, Type serviceType, params object[] additionalArguments);
62    }
63}