private static string BuildMessage(string[] argumentsUsed, ComponentModel componentModel, DefaultGenericHandler handler) { var message = string.Format( "Types {0} don't satisfy generic constraints of implementation type {1} of component '{2}'.", string.Join(", ", argumentsUsed), componentModel.Implementation.FullName, handler.ComponentModel.Name); if (handler.ImplementationMatchingStrategy == null) { return message + " This is most likely a bug in your code."; } return message + string.Format("this is likely a bug in the {0} used ({1})", typeof(IGenericImplementationMatchingStrategy).Name, handler.ImplementationMatchingStrategy); }
public virtual IHandler Create(ComponentModel model) { IHandler handler; if (model.RequiresGenericArguments) { handler = new DefaultGenericHandler(model); } else { handler = new DefaultHandler(model); } handler.Init(kernel); return handler; }
public GenericHandlerTypeMismatchException(IEnumerable<Type> argumentsUsed, ComponentModel componentModel, DefaultGenericHandler handler) : base(BuildMessage(argumentsUsed.Select(a => a.FullName).ToArray(), componentModel, handler), componentModel.ComponentName) { }
private static string BuildMessage(string[] argumentsUsed, ComponentModel componentModel, DefaultGenericHandler handler) { var message = string.Format( "Types {0} don't satisfy generic constraints of implementation type {1} of component '{2}'.", string.Join(", ", argumentsUsed), componentModel.Implementation.FullName, handler.ComponentModel.Name); if (handler.ImplementationMatchingStrategy == null) { return(message + " This is most likely a bug in your code."); } return(message + string.Format("this is likely a bug in the {0} used ({1})", typeof(IGenericImplementationMatchingStrategy).Name, handler.ImplementationMatchingStrategy)); }
public GenericHandlerTypeMismatchException(IEnumerable <Type> argumentsUsed, ComponentModel componentModel, DefaultGenericHandler handler) : base(BuildMessage(argumentsUsed.Select(a => a.FullName).ToArray(), componentModel, handler), componentModel.ComponentName) { }