/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

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