using Autofac;
using Nop.Core.Infrastructure;
using Nop.Core.Infrastructure.DependencyManagement;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Nop.Web.Framework.Mvc;
using Nop.Data;
using Nop.Core.Data;
using Autofac.Core;
using Nop.Plugin.SigmaSolve.StyleEditor.Domain;
using Nop.Plugin.SigmaSolve.StyleEditor.Data;
using Nop.Core.Configuration;
using Nop.Web.Framework.Infrastructure.Extensions;

namespace Nop.Plugin.SigmaSolve.StyleEditor.Infrastructure
{
    public class DependencyRegistrar : IDependencyRegistrar
    {
        private const string CONTEXT_NAME = "nop_object_context_product_StyleEditorRecord_Context";
         
        public void Register(ContainerBuilder builder, ITypeFinder typeFinder, NopConfig config)
        {
            //data context
            builder.RegisterPluginDataContext<StyleEditorContext>(CONTEXT_NAME);
            //override required repository with our custom context
            builder.RegisterType<EfRepository<StyleEditorRecord>>().As<IRepository<StyleEditorRecord>>()
                .WithParameter(ResolvedParameter.ForNamed<IDbContext>(CONTEXT_NAME))
                .InstancePerLifetimeScope();             
        }

        public int Order => 1;
    }

}
