﻿namespace MyCompany.MyProject.WebApi
{
    using Autofac;
    using System;

    /// <summary>
    /// Application configuration module for the <see cref="MyCompany.MyProject.WebApi"/> assembly.
    /// </summary>
    /// <seealso cref="Dike.Core.Modules.ApplicationModule" />
    [Dike.Core.Modules.DependsOn(typeof(MyProjectWebCoreModule))]
    public class WebApiModule
        : Dike.Core.Modules.ApplicationModule
    {
        #region Methods

        /// <summary>
        /// This method can be used to configure the dependencies injection registration.
        /// </summary>
        /// <remarks>By overriding this method, it is possible to customize the dependency injection registration process.
        /// <para>Typical are calls to <see cref="Dike.Core.Configuration.Startup.IStartupConfiguration.ReplaceService(Type, Action{ContainerBuilder})"/> to replace a core service by a custom implementation.</para>
        /// <para>Furthermore it is possible to modify the default dependency injection registration process represented by elements like
        /// <see cref=" Dike.Core.Dependency.IDependencyConfiguration.ConventionalRegistrars"/> in <see cref="Dike.Core.Configuration.Startup.IStartupConfiguration.Dependency"/>
        /// or <see cref="Dike.Core.Domain.UnitOfWork.IUnitOfWorkDefaultOptions.ConventionalUnitOfWorkSelectors"/> in <see cref="Dike.Core.Configuration.Startup.IStartupConfiguration.UnitOfWork"/>.</para>
        /// </remarks>
        public override void PreRegisterServices()
        {
        }

        /// <summary>
        /// Called before all modules are started.
        /// </summary>
        /// <param name="lifetimeScope">The lifetime scope.</param>
        public override void PreStartup(ILifetimeScope lifetimeScope)
        {
        }

        /// <summary>
        /// This method is used to register dependencies injection.
        /// </summary>
        /// <param name="builder">The container builder.</param>
        public override void RegisterServices(ContainerBuilder builder)
        {
            ////DependencyInjection.ServiceCollectionRegistrar.Register(builder);
        }

        /// <summary>
        /// Called when the application is being shutdown.
        /// </summary>
        /// <param name="lifetimeScope">The IoC lifetime scope.</param>
        public override void Shutdown(ILifetimeScope lifetimeScope)
        {
        }

        /// <summary>
        /// Startup of the module.
        /// </summary>
        /// <param name="lifetimeScope">The IoC lifetime scope.</param>
        public override void Startup(ILifetimeScope lifetimeScope)
        {
        }

        #endregion Methods
    }
}