﻿namespace Dike.Core.ObjectMapping
{
    using AutoMapper;
    using System;
    using System.Collections.Generic;

    /// <summary>
    /// Represents the configuration of the object mapping system.
    /// </summary>
    /// <seealso cref="Dike.Core.ObjectMapping.IMapperConfiguration" />
    internal class MapperConfiguration
        : IMapperConfiguration
    {
        #region Fields

        private static readonly Lazy<MapperConfiguration> _instance = new Lazy<MapperConfiguration>(() => new MapperConfiguration());

        #endregion Fields

        #region Constructors

        /// <summary>
        /// Prevents a default instance of the <see cref="MapperConfiguration"/> class from being created.
        /// </summary>
        private MapperConfiguration()
        {
            UseStaticMapper = true;
            Configurators = new List<Action<IMapperConfigurationExpression>>();
        }

        #endregion Constructors

        #region Properties

        /// <summary>
        /// Gets the singleton instance.
        /// </summary>
        /// <value>The singleton instance.</value>
        public static MapperConfiguration Instance
            => _instance.Value;

        /// <summary>
        /// Gets the list of mapping configurators.
        /// </summary>
        /// <value>A list of mapping configurators.</value>
        public List<Action<IMapperConfigurationExpression>> Configurators
        {
            get;
        }

        /// <summary>
        /// Gets or sets a value indicating whether to use a static mapper.
        /// </summary>
        /// <value><c>true</c> to use static mapper; otherwise, <c>false</c>.</value>
        /// <remarks>The default value is <c>true</c>.</remarks>
        public bool UseStaticMapper
        {
            get;
            set;
        }

        #endregion Properties
    }
}