PageRenderTime 58ms CodeModel.GetById 53ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/src/LinFu.IoC.Common/IContainer.cs

http://github.com/philiplaureano/LinFu
C# | 57 lines | 13 code | 5 blank | 39 comment | 0 complexity | 13a781d190584eac772512c2a40a75ff MD5 | raw file
 1using System;
 2using System.Collections.Generic;
 3
 4namespace LinFu.IoC.Interfaces
 5{
 6    /// <summary>
 7    ///     An inversion of control container interface.
 8    /// </summary>
 9    public interface IContainer
10    {
11        /// <summary>
12        ///     The list of services currently available inside the container.
13        /// </summary>
14        IEnumerable<IServiceInfo> AvailableServices { get; }
15
16        /// <summary>
17        ///     Determines whether or not a container will throw an exception
18        ///     if the requested service is not found.
19        /// </summary>
20        bool SuppressErrors { get; set; }
21
22        /// <summary>
23        ///     Adds an <see cref="IFactory" /> instance and associates it
24        ///     with the given <paramref name="serviceType">service type</paramref>.
25        /// </summary>
26        /// <param name="serviceType">The service type to associate with the factory</param>
27        /// <param name="additionalParameterTypes">The list of additional parameters that this factory type will support.</param>
28        /// <param name="factory">The <see cref="IFactory" /> instance that will be responsible for creating the service instance</param>
29        void AddFactory(Type serviceType, IEnumerable<Type> additionalParameterTypes, IFactory factory);
30
31        /// <summary>
32        ///     Determines whether or not the container can create
33        ///     the given <paramref name="serviceType">service type</paramref>.
34        /// </summary>
35        /// <param name="serviceType">
36        ///     The type of service used to determine whether or not the given service can actually be
37        ///     created
38        /// </param>
39        /// <param name="additionalParameterTypes">The list of additional parameters that this factory type will support.</param>
40        /// <returns>A <see cref="bool">boolean</see> value that indicates whether or not the service exists.</returns>
41        bool Contains(Type serviceType, IEnumerable<Type> additionalParameterTypes);
42
43        /// <summary>
44        ///     Causes the container to instantiate the service with the given
45        ///     <paramref name="serviceType">service type</paramref>. If the service type cannot be created, then an
46        ///     exception will be thrown if the <see cref="SuppressErrors" /> property
47        ///     is set to false. Otherwise, it will simply return null.
48        /// </summary>
49        /// <param name="serviceType">The service type to instantiate.</param>
50        /// <param name="additionalArguments">The additional arguments that will be used to instantiate the service type.</param>
51        /// <returns>
52        ///     If successful, it will return a service instance that is compatible with the given type;
53        ///     otherwise, it will just return a null value.
54        /// </returns>
55        object GetService(Type serviceType, params object[] additionalArguments);
56    }
57}