2016-12-11 14:08:58 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using Tapeti.Config;
|
|
|
|
|
|
|
|
|
|
namespace Tapeti.Default
|
|
|
|
|
{
|
|
|
|
|
public class DependencyResolverBinding : IBindingMiddleware
|
|
|
|
|
{
|
|
|
|
|
public void Handle(IBindingContext context, Action next)
|
|
|
|
|
{
|
|
|
|
|
next();
|
|
|
|
|
|
|
|
|
|
foreach (var parameter in context.Parameters.Where(p => !p.HasBinding && p.Info.ParameterType.IsClass))
|
2017-01-31 11:01:08 +00:00
|
|
|
|
parameter.SetBinding(messageContext => messageContext.DependencyResolver.Resolve(parameter.Info.ParameterType));
|
2016-12-11 14:08:58 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|