ExpressionLifetimeDescriptor
Represents a lifetime descriptor which applies to expressions.
using Stashbox.Registration;
using Stashbox.Resolution;
using System;
using System.Linq.Expressions;
using System.Runtime.CompilerServices;
namespace Stashbox.Lifetime
{
[System.Runtime.CompilerServices.NullableContext(1)]
[System.Runtime.CompilerServices.Nullable(0)]
public abstract class ExpressionLifetimeDescriptor : LifetimeDescriptor
{
[return: System.Runtime.CompilerServices.Nullable(2)]
private protected override Expression BuildLifetimeAppliedExpression(ServiceRegistration serviceRegistration, ResolutionContext resolutionContext, TypeInformation typeInformation)
{
Expression expressionForRegistration = LifetimeDescriptor.GetExpressionForRegistration(serviceRegistration, resolutionContext, typeInformation);
if (expressionForRegistration != null)
return ApplyLifetime(expressionForRegistration, serviceRegistration, resolutionContext, typeInformation.Type);
return null;
}
protected abstract Expression ApplyLifetime(Expression expression, ServiceRegistration serviceRegistration, ResolutionContext resolutionContext, Type resolveType);
}
}