using System.Web;
using BusinessSeller.Web.RestaurantSeller.Services.HttpContextProvider;
using BusinessSeller.Web.RestaurantSeller.Services.HttpContextProvider.Interfaces;
using StructureMap;

namespace BusinessSeller.Web.RestaurantSeller.MainSite
{
    public class StructureMapProvider
    {
        public static void RegisterMap()
        {
            ObjectFactory.Initialize(expression =>
            {
                expression.Scan(x =>
                {
                    x.Assembly("BusinessSeller.Web.RestaurantSeller.Services");
                    x.Assembly("BusinessSeller.Web.RestaurantSeller.Controllers");
                    x.Assembly("BusinessSeller.Web.RestaurantSeller.Models");
                    x.Assembly("BusinessSeller.Web.Core.Helpers");
                    x.Assembly("BusinessSeller.Services.ServiceAgents.User");
                    x.Assembly("BusinessSeller.Services.ServiceAgents.Listing");
                    x.Assembly("BusinessSeller.Services.ServiceAgents.Entities");
                    x.Assembly("BusinessSeller.Services.ServiceAgents.Location");
                    x.WithDefaultConventions();
                });

                expression.For<BusinessSeller.Services.ServiceAgents.Listing.ListingServiceBase>()
                   .Add(new BusinessSeller.Services.ServiceAgents.Listing.ListingServiceWrapper());
                expression.For<BusinessSeller.Services.ServiceAgents.Listing.Interfaces.IListingServiceAgent>()
                    .Add<BusinessSeller.Services.ServiceAgents.Listing.ListingServiceAgent>();

                expression.For<BusinessSeller.Services.ServiceAgents.User.UserServiceBase>()
                    .Add(new BusinessSeller.Services.ServiceAgents.User.UserServiceWrapper());
                expression.For<BusinessSeller.Services.ServiceAgents.User.Interfaces.IUserServiceAgent>()
                    .Add<BusinessSeller.Services.ServiceAgents.User.UserServiceAgent>();

                expression.For<BusinessSeller.Services.ServiceAgents.Location.LocationServiceBase>()
                    .Add(new BusinessSeller.Services.ServiceAgents.Location.LocationServiceWrapper());
                expression.For<BusinessSeller.Services.ServiceAgents.Location.Interfaces.ILocationServiceAgent>()
                    .Add<BusinessSeller.Services.ServiceAgents.Location.LocationServiceAgent>();

                expression.For<HttpContext>().Use(() => HttpContext.Current);
                expression.For<IHttpContextUserProvider>()
                     .Add<HttpContextUserProvider>();
            });
        }
    }
}