src/NUnit/Core/src/TaskTests/TaskTestCaseBlockMemberAssigner.cs
/// <summary>
/// <inheritdoc/>
/// If the activated instance is of type <see cref="IInitializableTaskTestCaseBlock"/>
/// its method <see cref="IInitializableTaskTestCaseBlock.Initialize"/> method will be called.
/// </summary>
/// <param name="collectorEntry"><inheritdoc/></param>
/// <param name="serviceProvider"><inheritdoc/></param>
/// <returns><inheritdoc/></returns>
If the activated instance is of type
its method  method will be called.
If the activated instance is of type its method method will be called .
public virtual ITaskTestCaseBlock AssignInstance(TaskTestCaseBlockMember collectorEntry, IServiceProvider? serviceProvider)
        {
            serviceProvider ??= EmptyServiceProvider.Instance;
            ITaskTestCaseBlock? instance = collectorEntry.Instance;
            if (instance is null) {
                var instanceType = collectorEntry.GetInstanceType();
                instance = (ITaskTestCaseBlock)ActivatorUtilities.GetServiceOrCreateInstance(serviceProvider, instanceType);
                if (instance is IInitializableTaskTestCaseBlock initializableInstance) {
                    initializableInstance.Initialize();
                }
                collectorEntry.SetInstance(instance);
            }
            return instance;
        }
public virtual ITaskTestCaseBlock AssignInstance ( TaskTestCaseBlockMember collectorEntry , IServiceProvider ? serviceProvider ) { serviceProvider ??= EmptyServiceProvider . Instance ; ITaskTestCaseBlock ? instance = collectorEntry . Instance ; if ( instance is null ) { var instanceType = collectorEntry . GetInstanceType ( ) ; instance = ( ITaskTestCaseBlock ) ActivatorUtilities . GetServiceOrCreateInstance ( serviceProvider , instanceType ) ; if ( instance is IInitializableTaskTestCaseBlock initializableInstance ) { initializableInstance . Initialize ( ) ; } collectorEntry . SetInstance ( instance ) ; } return instance ; }
If the activated instance is of type
its method  method will be called.
If the activated instance is of type its method method will be called .
None
collectorEntry
TaskTestCaseBlockMember
None
serviceProvider
IServiceProvider?
None