public T CreateInstance <T>(IFunctionInstanceEx functionInstance) { var disposer = functionInstance.InstanceServices.GetRequiredService <ScopeDisposable>(); disposer.Scope = serviceProvider.CreateScope(); return(serviceProvider.GetRequiredService <T>()); }
public T CreateInstance <T>(IFunctionInstanceEx functionInstance) { var scope = functionInstance.InstanceServices.GetService <ILifetimeScope>() ?? _serviceProvider.GetService <ILifetimeScope>(); // Some dependencies of ILoggerFactory are registered after // FunctionsStartup, thus not allowing us to get the // ILoggerFactory from Autofac container. // So we are retrieving it from InstanceServices. var loggerFactory = functionInstance.InstanceServices.GetService <ILoggerFactory>() ?? scope.Resolve <ILoggerFactory>(); scope.Resolve <ILoggerFactory>( new NamedParameter(LoggerModule.loggerFactoryParam, loggerFactory) ); // This will create the same ILogger of a regular ILogger not using DI. // This ILogger is scoped under the function trigger and will be disposed // right after the code execution. var functionName = functionInstance.FunctionDescriptor.ShortName; scope.Resolve <ILogger>( new NamedParameter(LoggerModule.functionNameParam, functionName) ); return(CreateInstance <T>(scope)); }
public object CreateInstance(IFunctionInstanceEx functionInstance) { return(CreateInstance()); }
public TReflected Create(IFunctionInstanceEx functionInstance) { return(default(TReflected)); }
T IJobActivatorEx.CreateInstance <T>(IFunctionInstanceEx functionInstance) { _instanceServices.Add(functionInstance, functionInstance.InstanceServices); return(_innerActivator.CreateInstance <T>(functionInstance)); }
public T Create(IFunctionInstanceEx functionInstance) { return(_createInstance(functionInstance)); }
public object CreateInstance(IFunctionInstanceEx functionInstance) { return(_instanceFactory.Create(functionInstance)); }
public T CreateInstance <T>(IFunctionInstanceEx functionInstance) { return(CreateInstance <T>(functionInstance.InstanceServices)); }
public object CreateInstance(IFunctionInstanceEx functionInstance) { return(_inner.CreateInstance(functionInstance)); }