z4kn4fein / stashbox

A lightweight, fast, and portable dependency injection framework for .NET-based solutions.

Home Page:https://z4kn4fein.github.io/stashbox

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Please restore ResolutionContext.GetDependencyOverrideOrDefault in v5.0.0

schuettecarsten opened this issue · comments

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?

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