ResolutionRequestLifetime
Represents a per resolution request lifetime.
using Stashbox.BuildUp;
using Stashbox.Registration;
using Stashbox.Resolution;
using System;
using System.Linq.Expressions;
namespace Stashbox.Lifetime
{
public class ResolutionRequestLifetime : ScopedLifetimeBase
{
public override ILifetime Create()
{
return new ResolutionRequestLifetime();
}
public override Expression GetExpression(IContainerContext containerContext, IServiceRegistration serviceRegistration, IObjectBuilder objectBuilder, ResolutionContext resolutionContext, Type resolveType)
{
ParameterExpression knownVariableOrDefault = resolutionContext.GetKnownVariableOrDefault(ScopeId);
if (knownVariableOrDefault != null)
return knownVariableOrDefault;
Expression expression = base.GetExpression(containerContext, serviceRegistration, objectBuilder, resolutionContext, resolveType);
if (expression != null)
return StoreExpressionIntoLocalVariable(expression, resolutionContext, resolveType);
return null;
}
}
}