src/Microsoft/DependencyInjection/0/src/LifetimeServiceActivator.cs
/// <summary>
/// If <paramref name="descriptor"/> has instance it gets returned.
/// If <paramref name="descriptor"/> has factory the result gets returned.
/// Otherwise the instance will be created by using the implemenetation type.
/// </summary>
/// <param name="serviceProvider">
/// The service provider that is going to be passed to factory or used for
/// instance creation by implementation type and <see cref="ActivatorUtilities"/>.
/// </param>
/// <param name="descriptor">Describes the instance.</param>
/// <returns></returns>
If  has instance it gets returned.
If  has factory the result gets returned.
Otherwise the instance will be created by using the implemenetation type.
If has instance it gets returned . If has factory the result gets returned . Otherwise the instance will be created by using the implemenetation type .
public static object GetInstanceOrCreateInstance<TProvider>(TProvider serviceProvider, LifetimeServiceDescriptor<TProvider> descriptor)
            where TProvider : class, IServiceProvider
        {
            if (!(descriptor.ImplementationInstance is null)) {
                return descriptor.ImplementationInstance;
            }
            if (!(descriptor.ImplementationFactory is null)) {
                return descriptor.ImplementationFactory(serviceProvider);
            }
            return ActivatorUtilities.CreateInstance(serviceProvider, descriptor.ImplementationType!);
        }
public static object GetInstanceOrCreateInstance < TProvider > ( TProvider serviceProvider , LifetimeServiceDescriptor < TProvider > descriptor ) where TProvider : class , IServiceProvider { if ( ! ( descriptor . ImplementationInstance is null ) ) { return descriptor . ImplementationInstance ; } if ( ! ( descriptor . ImplementationFactory is null ) ) { return descriptor . ImplementationFactory ( serviceProvider ) ; } return ActivatorUtilities . CreateInstance ( serviceProvider , descriptor . ImplementationType ! ) ; }
If  has instance it gets returned.
If has instance it gets returned .
None
serviceProvider
TProvider
The service provider that is going to be passed to factory or used for
instance creation by implementation type and .
The service provider that is going to be passed to factory or used for instance creation by implementation type and .
descriptor
LifetimeServiceDescriptor<TProvider>
Describes the instance.
Describes the instance .