PageRenderTime 23ms CodeModel.GetById 20ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/src/LinFu.IoC/Interceptors/ProxyContainerPlugin.cs

http://github.com/philiplaureano/LinFu
C# | 43 lines | 20 code | 5 blank | 18 comment | 0 complexity | 49e0d421cf70866ad2e07d3372e808e7 MD5 | raw file
 1using LinFu.IoC.Configuration.Interfaces;
 2using LinFu.IoC.Interfaces;
 3
 4namespace LinFu.IoC.Interceptors
 5{
 6    /// <summary>
 7    ///     A <see cref="IContainerPlugin" /> implementation that inserts
 8    ///     <see cref="ProxyInjector" /> instances at the beginning of a <see cref="IServiceContainer" />
 9    ///     loading sequence.
10    /// </summary>
11    internal class ProxyContainerPlugin : IContainerPlugin
12    {
13        private readonly ProxyInjector _injector;
14
15        /// <summary>
16        ///     Initializes the class with the given <see cref="ProxyInjector" /> instance.
17        /// </summary>
18        /// <param name="injector">The postprocessor that will inject proxies in place of actual service requests.</param>
19        internal ProxyContainerPlugin(ProxyInjector injector)
20        {
21            _injector = injector;
22        }
23
24
25        /// <summary>
26        ///     Injects a <see cref="ProxyInjector" /> into the <paramref name="target">target container</paramref>.
27        /// </summary>
28        /// <param name="target">The service container that will hold the <see cref="ProxyInjector" />.</param>
29        public void BeginLoad(IServiceContainer target)
30        {
31            target.PostProcessors.Add(_injector);
32        }
33
34        /// <summary>
35        ///     Does absolutely nothing.
36        /// </summary>
37        /// <param name="target">The target container.</param>
38        public void EndLoad(IServiceContainer target)
39        {
40            // Do nothing
41        }
42    }
43}