using System.Web.Mvc;
using Microsoft.Practices.Unity;
using Unity.Mvc5;
using CatalogSupport.Models;
using Microsoft.AspNet.Identity;
using Microsoft.AspNet.Identity.EntityFramework;
using CatalogSupport.Controllers;
using System;

namespace CatalogSupport
{
    public static class UnityConfig
    {

        private static UnityContainer instance = new UnityContainer();


        public static UnityContainer Instance
        {
            get
            {
                return instance;
            }
        }

        public static void RegisterComponents()
        {
            

            // register all your components with the container here
            // it is NOT necessary to register your controllers

            // e.g. container.RegisterType<ITestService, TestService>();
        

            DependencyResolver.SetResolver(new UnityDependencyResolver(instance));
        }

        public static T Retrieve<T>()
        {
            return instance.Resolve<T>();
        }

        public static object GetDeviceService(string productType)
        {
            string serviceName = "Business.Contracts.Interface.I" + productType + "Service";
            Type type = Type.GetType(serviceName + ", Business.Contracts");
            return instance.Resolve(type);
        }


        //public static object GetDeviceRepository(string productType)
        //{
        //    string repositoryName = "CatalogSupport.DALCommon.Interface.I" + productType + "Repository";
        //    Type type = Type.GetType(repositoryName + ", CatalogSupport.DALCommon.");
        //    return instance.Resolve(type);
        //}
    }


}