using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using qdr.app.bundleboiler.data.Model;
using qdr.app.bundleboiler.ui.Configuration;
using qdr.app.bundleboiler.ui.Dialogs;
using Quadarax.Foundation.Core.Business.Injection;
using Quadarax.Foundation.Core.Logging;
using System.Windows.Forms;

namespace bundleboiler.ui
{
    public partial class MainForm : Form
    {
        #region *** Private fields ***
        ILog? _log;
        #endregion

        #region *** Constructor ***
        public MainForm(Quadarax.Foundation.Core.Logging.ILogger? logger)
        {
            InitializeComponent();
            _log = logger?.GetLogger(GetType().Name);
            InitializeInternal();
        }
        #endregion

        #region *** Private operations ***
        #region **** Initialiation ****
        private void InitializeInternal()
        {
            var loggerFactory = new Quadarax.Foundation.Core.NLog.LoggerFactory();
            try
            {
              throw new Exception("Cannot initialize application");
            }
            catch (Exception e)
            {
                new ErrorMessageDialog(loggerFactory, "Cannot initialize application", e).ShowDialog();
            }
        }
        #endregion
        #region **** Logging ****
        private void LogDebug(string message)
        {
            _log?.Log(LogSeverityEnum.Debug, message);
        }
        #endregion
        #endregion
    }
}
