Skip to content

Commit

Permalink
change container.Register to container.Collection.Register
Browse files Browse the repository at this point in the history
Updated for the Pipeline types. This fixes the SimpleInjector error:

The supplied list of types contains one or multiple open generic types, but this method is unable to handle open generic types because it can only map closed generic service types to a single implementation. You must register the open-generic types separately using the Register(Type, Type) overload. Alternatively, try using Container.Collection.Register instead, if you expect to have multiple implementations per closed-generic abstraction.
  • Loading branch information
ojraqueno committed Jun 6, 2018
1 parent 242edcd commit ce7a7c7
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions samples/MediatR.Examples.SimpleInjector/Program.cs
Expand Up @@ -38,14 +38,14 @@ private static IMediator BuildMediator(WrappingWriter writer)
container.Register(() => (TextWriter)writer, Lifestyle.Singleton);

//Pipeline
container.Register(typeof(IPipelineBehavior<,>), new []
container.Collection.Register(typeof(IPipelineBehavior<,>), new []
{
typeof(RequestPreProcessorBehavior<,>),
typeof(RequestPostProcessorBehavior<,>),
typeof(GenericPipelineBehavior<,>)
});
container.Register(typeof(IRequestPreProcessor<>), new [] { typeof(GenericRequestPreProcessor<>) });
container.Register(typeof(IRequestPostProcessor<,>), new[] { typeof(GenericRequestPostProcessor<,>), typeof(ConstrainedRequestPostProcessor<,>) });
container.Collection.Register(typeof(IRequestPreProcessor<>), new [] { typeof(GenericRequestPreProcessor<>) });
container.Collection.Register(typeof(IRequestPostProcessor<,>), new[] { typeof(GenericRequestPostProcessor<,>), typeof(ConstrainedRequestPostProcessor<,>) });

container.Register(() => new ServiceFactory(container.GetInstance), Lifestyle.Singleton);

Expand Down

0 comments on commit ce7a7c7

Please sign in to comment.