using System;
using System.Web.Mvc;
using PageAdmin.Common;using PageAdmin.Utils.ORM;using PageAdmin.Utils;
using System.Web.Routing;
using System.Collections.Generic;

namespace PageAdmin.Web.Areas.Admin
{
    public class AdminAreaRegistration : AreaRegistration
    {
        public override string AreaName
        {
            get
            {
                return "Admin";
            }
        }

        public override void RegisterArea(AreaRegistrationContext context)
        {
            string adminPath = SystemConfig.Get().AdminPath;
            //string adminDomain = SystemConfig.Get().AdminDomain;//后台不开放子域名绑定
            string adminDomain = "";
            if (string.IsNullOrEmpty(adminDomain))
            {
                adminDomain = SystemConfig.Get().Domain;
                adminPath += "/";
            }
            else
            {
                adminPath = "";
            }
            context.MapRoute(
                        "admin_default",
                        adminPath + "{controller}/{action}",
                        new { controller = "Default", action = "Index", adminPath = adminPath},
                        new { domainConstraint = new DomainConstraint(adminDomain), areaConstraint=new AreaConstraint("Admin")},
                        new string[] { "PageAdmin.Web.Areas.Admin.Controllers" }
                        );
        }
    }
}