public static void CleanUpDependencies(this ExecutionContext executionContext) { if (ServiceScopeDictionary.TryRemove(executionContext.InvocationId, out var scope)) { scope.Dispose(); } }
public async Task <IValueProvider> BindAsync(BindingContext context) { await Task.Yield(); var scope = ServiceScopeDictionary.GetOrAdd(context.FunctionInstanceId, (_) => _serviceProvider.CreateScope()); var value = scope.ServiceProvider.GetRequiredService(_type); return(await BindAsync(value, context.ValueContext)); }