src/packages/EmbedIO/WebApi/WebApiModuleBase.cs
/// <summary>
/// <para>Registers a controller type using a constructor.</para>
/// <para>In order for registration to be successful, the specified <paramref name="controllerType"/>: </para>
/// <list type="bullet">
/// <item><description>must be a subclass of <see cref="WebApiController"/>;</description></item>
/// <item><description>must not be an abstract class;</description></item>
/// <item><description>must not be a generic type definition;</description></item>
/// <item><description>must have a public parameterless constructor.</description></item>
/// </list>
/// </summary>
/// <param name="controllerType">The type of the controller.</param>
/// <exception cref="InvalidOperationException">The module's configuration is locked.</exception>
/// <exception cref="ArgumentNullException"><paramref name="controllerType"/> is <see langword="null"/>.</exception>
/// <exception cref="ArgumentException">
/// <para><paramref name="controllerType"/> is already registered in this module.</para>
/// <para>- or -</para>
/// <para><paramref name="controllerType"/> does not satisfy the prerequisites
/// listed in the Summary section.</para>
/// </exception>
/// <remarks>
/// <para>A new instance of <paramref name="controllerType"/> will be created
/// for each request to handle, and dereferenced immediately afterwards,
/// to be collected during next garbage collection cycle.</para>
/// <para><paramref name="controllerType"/> is not required to be thread-safe,
/// as it will be constructed and used in the same synchronization context.
/// However, since request handling is asynchronous, the actual execution thread
/// may vary during execution. Care must be exercised when using thread-sensitive
/// resources or thread-static data.</para>
/// <para>If <paramref name="controllerType"/> implements <see cref="IDisposable"/>,
/// its <see cref="IDisposable.Dispose">Dispose</see> method will be called when it has
/// finished handling a request.</para>
/// </remarks>
/// <seealso cref="RegisterControllerType(Type,Func{WebApiController})"/>
/// <seealso cref="RegisterControllerType{TController}()"/>
Registers a controller type using a constructor.In order for registration to be successful, the specified : must be a subclass of ;must not be an abstract class;must not be a generic type definition;must have a public parameterless constructor.
Registers a controller type using a constructor . In order for registration to be successful the specified : must be a subclass of ; must not be an abstract class ; must not be a generic type definition ; must have a public parameterless constructor .
protected void RegisterControllerType(Type controllerType)
        {
            EnsureConfigurationNotLocked();
            controllerType = ValidateControllerType(nameof(controllerType), controllerType, false);
            var constructor = controllerType.GetConstructors().FirstOrDefault(c => c.GetParameters().Length == 0);
            if (constructor == null)
            {
                throw new ArgumentException(
                    "Controller type must have a public parameterless constructor.",
                    nameof(controllerType));
            }
            if (!TryRegisterControllerTypeCore(controllerType, Expression.New(constructor)))
                throw new ArgumentException($"Type {controllerType.Name} contains no controller methods.");
        }
protected void RegisterControllerType ( Type controllerType ) { EnsureConfigurationNotLocked ( ) ; controllerType = ValidateControllerType ( nameof ( controllerType ) , controllerType , false ) ; var constructor = controllerType . GetConstructors ( ) . FirstOrDefault ( c => c . GetParameters ( ) . Length == 0 ) ; if ( constructor == null ) { throw new ArgumentException ( " " , nameof ( controllerType ) ) ; } if ( ! TryRegisterControllerTypeCore ( controllerType , Expression . New ( constructor ) ) ) throw new ArgumentException ( $" Type  { controllerType . Name }  contains no controller methods. " ) ; }
Registers a controller type using a constructor.In order for registration to be successful, the specified : must be a subclass of ;must not be an abstract class;must not be a generic type definition;must have a public parameterless constructor.
Registers a controller type using a constructor . In order for registration to be successful the specified : must be a subclass of ; must not be an abstract class ; must not be a generic type definition ; must have a public parameterless constructor .
The module's configuration is locked.
The module ' s configuration is locked .
None
None
controllerType
Type
The type of the controller.
The type of the controller .
remarks
A new instance of  will be created
for each request to handle, and dereferenced immediately afterwards,
to be collected during next garbage collection cycle. is not required to be thread-safe,
as it will be constructed and used in the same synchronization context.
However, since request handling is asynchronous, the actual execution thread
may vary during execution. Care must be exercised when using thread-sensitive
resources or thread-static data.If  implements ,
its Dispose
A new instance of will be created for each request to handle and dereferenced immediately afterwards to be collected during next garbage collection cycle . is not required to be thread - safe as it will be constructed and used in the same synchronization context . However since request handling is asynchronous the actual execution thread may vary during execution . Care must be exercised when using thread - sensitive resources or thread - static data . If implements its Dispose
seealso
None
seealso
None