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

/src/LinFu.IoC.Common/ImplementsAttribute.cs

http://github.com/philiplaureano/LinFu
C# | 51 lines | 19 code | 5 blank | 27 comment | 0 complexity | 0131c0d1a73691f5bb23e2f0fb7e3e6c MD5 | raw file
 1using System;
 2
 3namespace LinFu.IoC.Configuration
 4{
 5    /// <summary>
 6    ///     The attribute used to specify how a service should be implemented
 7    ///     in addition to its instancing behavior.
 8    /// </summary>
 9    [AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
10    public class ImplementsAttribute : Attribute
11    {
12        /// <summary>
13        ///     The name to associate with the given service.
14        /// </summary>
15        public string ServiceName;
16
17        /// <summary>
18        ///     Allows users to add services to a container using a
19        ///     given <paramref name="serviceType">service type</paramref>.
20        /// </summary>
21        /// <remarks>By default, each service will be created once per request.</remarks>
22        /// <param name="serviceType">The <see cref="System.Type" /> of service to implement.</param>
23        public ImplementsAttribute(Type serviceType) : this(serviceType, LifecycleType.OncePerRequest)
24        {
25        }
26
27        /// <summary>
28        ///     Allows users to add services to a container using a
29        ///     given <paramref name="serviceType">service type</paramref> and
30        ///     <paramref name="lifeCycleType">lifecycle type</paramref>.
31        /// </summary>
32        /// <param name="serviceType">The <see cref="System.Type" /> of service to implement.</param>
33        /// <param name="lifeCycleType">The instancing behavior to use with this implementation.</param>
34        public ImplementsAttribute(Type serviceType, LifecycleType lifeCycleType)
35        {
36            ServiceType = serviceType;
37            LifecycleType = lifeCycleType;
38        }
39
40        /// <summary>
41        ///     The type of service that will be implemented.
42        /// </summary>
43        public Type ServiceType { get; }
44
45        /// <summary>
46        ///     The instancing behavior of the service instance.
47        /// </summary>
48        /// <seealso cref="LifecycleType" />
49        public LifecycleType LifecycleType { get; }
50    }
51}