billbogaiv / hybrid-model-binding

Provides the ability to bind models using both ModelBinder and ValueProvider in ASP.NET Core.
MIT License
104 stars 19 forks source link

FYI, a cleaner way to access Services in AddHybridModelBinder() #50

Closed ericsampson closed 3 years ago

ericsampson commented 3 years ago

I noticed that here in AddHybridModelBinder() that it's building a serviceprovider.

There's a cleaner way to do this, that doesn't require building an intermediate serviceprovider (and the drawbacks it entails): https://andrewlock.net/accessing-services-when-configuring-mvcoptions-in-asp-net-core/

I don't have time right this second to make a PR, but wanted to note it at least.

Cheers!

billbogaiv commented 3 years ago

Thanks for the feedback. That was fun to implement.