title: Mediator pipline behaviors registration
body: <p>I have a asp.net core web api project with Mediatr 3.0.1 and structureMap.Microsoft.DependencyInjection 1.4.0.</p>
  
  <p>I would like to use the pre and post-processing behavior.
  The IPipelineBehavior works as expected but thoese 2 don't:</p>
  
  <pre><code>public class PostProcessingBehavior&lt;TRequest, TResponse&gt; : IRequestPostProcessor&lt;TRequest, TResponse&gt;
  {
      public Task Process(TRequest request, TResponse response)
      {
          LogTo.Info("Post processing: All Done");
          return Task.FromResult(0);
      }
  }
  
  public class PreProcessingBehavior&lt;TRequest&gt;: IRequestPreProcessor&lt;TRequest&gt;
  {
      public Task Process(TRequest request)
      {
          // add validators here
          LogTo.Info("Pipline preprocessing happens");
  
          return Task.FromResult(0);
      }
  }
  </code></pre>
  
  <p>Container registration:</p>
  
  <pre><code>private IServiceProvider ConfigureIoC(IServiceCollection services)
  {
      var container = new Container();
      container.Configure(cfg =&gt;
      {
          cfg.Scan(scanner =&gt;
          {
              scanner.AssemblyContainingType(typeof(Startup));
              scanner.AssemblyContainingType(typeof(CustomerGetHandler));
              scanner.ConnectImplementationsToTypesClosing(typeof(IRequestHandler&lt;&gt;)); // Handlers with no response
              scanner.ConnectImplementationsToTypesClosing(typeof(IRequestHandler&lt;,&gt;)); // Handlers with a response
              scanner.ConnectImplementationsToTypesClosing(typeof(IAsyncRequestHandler&lt;&gt;)); // Async handlers with no response
              scanner.ConnectImplementationsToTypesClosing(typeof(IAsyncRequestHandler&lt;,&gt;)); // Async Handlers with a response
              scanner.ConnectImplementationsToTypesClosing(typeof(INotificationHandler&lt;&gt;));
              scanner.ConnectImplementationsToTypesClosing(typeof(IAsyncNotificationHandler&lt;&gt;));
              scanner.WithDefaultConventions();
          });
  
          cfg.For(typeof(IPipelineBehavior&lt;,&gt;)).Add(typeof(PreProcessingBehavior&lt;&gt;));
          cfg.For(typeof(IPipelineBehavior&lt;,&gt;)).Add(typeof(LoggingBehavior&lt;,&gt;));
          cfg.For(typeof(IPipelineBehavior&lt;,&gt;)).Add(typeof(PostProcessingBehavior&lt;,&gt;));
  
          cfg.For&lt;SingleInstanceFactory&gt;().Use&lt;SingleInstanceFactory&gt;(ctx =&gt; t =&gt; ctx.GetInstance(t)).ContainerScoped();
          cfg.For&lt;MultiInstanceFactory&gt;().Use&lt;MultiInstanceFactory&gt;(ctx =&gt; t =&gt; ctx.GetAllInstances(t)).ContainerScoped();
          cfg.For&lt;IMediator&gt;().Use&lt;Mediator&gt;();
  
          cfg.Populate(services);
      });
  
      return container.GetInstance&lt;IServiceProvider&gt;();
  }
  </code></pre>
  
  <p>The error says:<br>
  ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
  Parameter name: instance 'PostProcessingBehavior' with ReturnType PostProcessingBehavior cannot be cast to IPipelineBehavior</p>
  
  <p>this is from the example:
  <a href="https://github.com/jbogard/MediatR/blob/master/samples/MediatR.Examples.StructureMap/Program.cs" rel="nofollow noreferrer">https://github.com/jbogard/MediatR/blob/master/samples/MediatR.Examples.StructureMap/Program.cs</a> </p>