public override ResolveDelegate <BuilderContext>?Build(ref PipelineBuilder builder) { return(builder.Registration.LifetimeManager switch { null => TransientLifetime(ref builder), TransientLifetimeManager _ => TransientLifetime(ref builder), PerResolveLifetimeManager _ => PerResolveLifetime(ref builder), ILifetimeManagerAsync _ => AsyncLifetime(ref builder), _ => DefaultLifetime(ref builder) });
private ILifetimePolicy GetLifetimePolicy(IBuilderContext context) { ILifetimePolicy policy = context.Policies.GetNoDefault<ILifetimePolicy>(context.BuildKey, false); if (policy == null && context.BuildKey.Type.GetTypeInfo().IsGenericType) { policy = this.GetLifetimePolicyForGenericType(context); } if (policy == null) { policy = new TransientLifetimeManager(); context.PersistentPolicies.Set<ILifetimePolicy>(policy, context.BuildKey); } return policy; }