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

/src/LinFu.IoC/NamedServiceNotFoundException.cs

http://github.com/philiplaureano/LinFu
C# | 37 lines | 18 code | 3 blank | 16 comment | 0 complexity | fc63672a4c767a59a4d908b407590f46 MD5 | raw file
 1using System;
 2
 3namespace LinFu.IoC
 4{
 5    /// <summary>
 6    ///     The exception thrown when a service name and a service type is
 7    ///     requested from a named container and that named container
 8    ///     is unable to find or create that particular service instance.
 9    /// </summary>
10    [Serializable]
11    public class NamedServiceNotFoundException : ServiceNotFoundException
12    {
13        private readonly string _serviceName;
14        private readonly Type _serviceType;
15
16        /// <summary>
17        ///     Initializes the service exception using the
18        ///     given <paramref name="serviceType" /> as
19        ///     the service that was not found.
20        /// </summary>
21        /// <param name="serviceType">The service type being requested.</param>
22        /// <param name="serviceName">The name of the service being requested.</param>
23        public NamedServiceNotFoundException(string serviceName, Type serviceType) : base(serviceType)
24        {
25            _serviceName = serviceName;
26            _serviceType = serviceType;
27        }
28
29        /// <summary>
30        ///     The error message that this particular exception
31        ///     will display.
32        /// </summary>
33        public override string Message => string.Format("Unable to find a service named '{0}' with type '{1}'",
34            _serviceName,
35            _serviceType.AssemblyQualifiedName);
36    }
37}