1
0
mirror of synced 2024-11-04 18:49:16 +00:00
Tapeti/Default/DependencyResolverBinding.cs

18 lines
514 B
C#

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))
parameter.SetBinding(messageContext => messageContext.DependencyResolver.Resolve(parameter.Info.ParameterType));
}
}
}