z4kn4fein / stashbox

A lightweight, fast, and portable dependency injection framework for .NET-based solutions.
https://z4kn4fein.github.io/stashbox
MIT License
141 stars 10 forks source link

Please restore ResolutionContext.GetDependencyOverrideOrDefault in v5.0.0 #111

Closed schuettecarsten closed 2 years ago

schuettecarsten commented 2 years ago

In v5.0.0, the method ResolutionContext.GetDependencyOverrideOrDefault was removed. I use this method in my code to make sure that a specific value was passed into the Resolve call and not created by the Container itself. So, I kindly ask you to restore that functionality.

Sample:

    var tenant = context.GetDependencyOverrideOrDefault<AadTenant>();
    if (tenant == null)
    {
        throw new InvalidOperationException("AAD tenant entity should be passed into the resolver as dependency override!");
    }

I found the new method GetExpressionOverrideOrDefault, but I am usure if I can use this to query an ConstantExpression and use the Value? Is that a valid workaround?

schuettecarsten commented 2 years ago

Ok, I just found out that IResolutionContext was renamed to IRequestContext.