using System; using System.Linq; using Tapeti.Config; namespace Tapeti.Default { /// /// /// Attempts to resolve any unhandled parameters to Controller methods using the IoC container. /// This middleware is included by default in the standard TapetiConfig. /// public class DependencyResolverBinding : IControllerBindingMiddleware { /// public void Handle(IControllerBindingContext context, Action next) { next(); foreach (var parameter in context.Parameters.Where(p => !p.HasBinding && p.Info.ParameterType.IsClass)) parameter.SetBinding(messageContext => messageContext.Config.DependencyResolver.Resolve(parameter.Info.ParameterType)); } } }