Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix runtime exception in DryIoc sample #881

Merged
merged 1 commit into from
Mar 27, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions samples/MediatR.Examples.DryIoc/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,17 @@ static Task Main()
private static IMediator BuildMediator(WrappingWriter writer)
{
var container = new Container();
// Since Mediator has multiple constructors, consider adding rule to allow that
// var container = new Container(rules => rules.With(FactoryMethod.ConstructorWithResolvableArguments))

container.Use<TextWriter>(writer);

//Pipeline works out of the box here

container.RegisterMany(new[] { typeof(IMediator).GetAssembly(), typeof(Ping).GetAssembly() }, Registrator.Interfaces);
//Without the container having FactoryMethod.ConstructorWithResolvableArguments commented above
//You must select the desired constructor
container.Register<IMediator, Mediator>(made: Made.Of(() => new Mediator(Arg.Of<IServiceProvider>())));

var services = new ServiceCollection();

Expand Down