iSchedulerAreaRegistration.cs 4.31 KB
using System;
using System.Web;
using System.Web.Mvc;
using System.Web.Optimization;
using Vrh.iScheduler;

namespace Vrh.Web.iScheduler.Areas.iScheduler
{
    /// <summary>
    /// Az iScheduler area regisztrációja.
    /// </summary>
    public class iSchedulerAreaRegistration : AreaRegistration
    {
        /// <summary>
        /// Csak olvasható tulajdonság, mely konstans módon visszaadja az area nevét.
        /// </summary>
        public override string AreaName
        {
            get { return SchConst.AREA; }
        }

        /// <summary>
        /// Az area regisztrációjának belépési pontja.
        /// </summary>
        /// <remarks>
        /// Ide kell tenni minden olyan dolgot, 
        /// melyet az area felélesztésekor el kell végezni.
        /// Például:
        /// - a szókódok inicializálása
        /// - vagy a komponens működéséhez szükséges adatbázis migrációjának elvégzése
        /// </remarks>
        /// <param name="context"></param>
        public override void RegisterArea(AreaRegistrationContext context)
        {
            RegisterRoutes(context);
            RegisterBundles(BundleTable.Bundles);

            //nyelvi fordítások inicializálása
            VRH.Log4Pro.MultiLanguageManager.MultiLanguageManager.InitializeWordCodes(typeof(SchedulerWordCodes));

        }

        private void RegisterRoutes(AreaRegistrationContext context)
        {
            if (context == null) { throw new ArgumentNullException("context"); }

            context.MapRoute(
                this.AreaName + "_default",
                this.AreaName + "/{controller}/{action}/{id}",
                new { action = "Index", id = UrlParameter.Optional }
            );
        }

        private void RegisterBundles(BundleCollection bundles)
        {
            if (bundles == null) { throw new ArgumentNullException("bundles"); }

            string contentPrefix = string.Concat("~/Areas/", this.AreaName, "/Content/");
            string scriptsPrefix = string.Concat("~/Areas/", this.AreaName, "/Scripts/");

            #region Content - Componens (area) CSS összetevői

            bundles.Add(new StyleBundle(SchConst.BUNDLES_STYLE_FOR_EDITOR).Include(
                "~/Content/themes/base/autocomplete.css",
                string.Concat(contentPrefix, "bootstrap-datetimepicker.min.css"),
                string.Concat(contentPrefix, "Editor.css")
            ));

            bundles.Add(new StyleBundle(SchConst.BUNDLES_STYLE_FOR_MANAGER).Include(
                "~/Content/DataTables/css/dataTables.bootstrap4.min.css",
                string.Concat(contentPrefix, "bootstrap-toggle.css"),
                string.Concat(contentPrefix, "Manager.css")
            ));

            bundles.Add(new StyleBundle(SchConst.BUNDLES_STYLE_FOR_MANAGERCALENDAR).Include(
                "~/Content/fullcalendar.min.css",
                string.Concat(contentPrefix, "bootstrap-toggle.css"),
                string.Concat(contentPrefix, "ManagerCalendar.css")
            ));

            #endregion Content - Componens (area) CSS összetevői

            #region Scripts - Componens (area) javascript összetevői

            bundles.Add(new ScriptBundle(SchConst.BUNDLES_SCRIPT_FOR_EDITOR).Include(
                "~/Scripts/moment-with-locales.min.js",
                "~/Scripts/jquery-ui-1.13.2.min.js",
                string.Concat(scriptsPrefix, "bootstrap-datetimepicker.min.js"),
                string.Concat(scriptsPrefix, "Editor.js")
            ));

            bundles.Add(new ScriptBundle(SchConst.BUNDLES_SCRIPT_FOR_MANAGER).Include(
                "~/Scripts/DataTables/jquery.dataTables.min.js",
                "~/Scripts/DataTables/dataTables.bootstrap4.min.js",
                "~/Scripts/moment-with-locales.min.js",
                string.Concat(scriptsPrefix, "bootstrap-toggle.js"),
                string.Concat(scriptsPrefix, "Manager.js")
            ));

            bundles.Add(new ScriptBundle(SchConst.BUNDLES_SCRIPT_FOR_MANAGERCALENDAR).Include(
                "~/Scripts/moment-with-locales.min.js",
                "~/Scripts/jquery-ui-1.13.2.min.js",
                "~/Scripts/fullcalendar.min.js",
                string.Concat(scriptsPrefix, "bootstrap-toggle.js")
            ));

            #endregion Scripts - Componens (area) javascript összetevői
        }
    }
}