using System; using System.Collections.Generic; using System.Linq; namespace Swan.DependencyInjection { /// /// Generic Constraint Registration Exception. /// /// public class DependencyContainerRegistrationException : Exception { private const String ConvertErrorText = "Cannot convert current registration of {0} to {1}"; private const String RegisterErrorText = "Cannot register type {0} - abstract classes or interfaces are not valid implementation types for {1}."; /*private const String ErrorText = "Duplicate implementation of type {0} found ({1}).";*/ /*/// /// Initializes a new instance of the class. /// /// Type of the register. /// The types. public DependencyContainerRegistrationException(Type registerType, IEnumerable types) : base(String.Format(ErrorText, registerType, GetTypesString(types))) { }*/ /// /// Initializes a new instance of the class. /// /// The type. /// The method. /// if set to true [is type factory]. public DependencyContainerRegistrationException(Type type, String method, Boolean isTypeFactory = false) : base(isTypeFactory ? String.Format(RegisterErrorText, type.FullName, method) : String.Format(ConvertErrorText, type.FullName, method)) { } /*private static String GetTypesString(IEnumerable types) => String.Join(",", types.Select(type => type.FullName));*/ } }