コード例 #1
0
        public static Route RegisterRoutes(this AreaRegistrationContext context, string name, string url, object defaults)
        {
            Route route = null;

            if (WebConstants.MultiLanguageAreas == MultiLanguageRoutingOptions.Both || WebConstants.MultiLanguageAreas == MultiLanguageRoutingOptions.OnlyLanguageBased)
            {
                var _defaults = (new { lang = LangRouteConstraint.DefaultLanguage }).Extend(defaults);

                route = context.MapRouteWithName(
                    name: $"{context.AreaName}_{name}_nud_LangBased",
                    url: $"{{lang}}/{context.AreaName}/{url}",
                    defaults: _defaults,
                    constraints: new { lang = new LangRouteConstraint() }
                    );
            }

            if (WebConstants.MultiLanguageAreas == MultiLanguageRoutingOptions.Both || WebConstants.MultiLanguageAreas == MultiLanguageRoutingOptions.None)
            {
                route = context.MapRouteWithName(
                    name: $"{context.AreaName}_{name}_nud",
                    url: $"{context.AreaName}/{url}",
                    defaults: defaults
                    );
            }

            return(route);
        }
コード例 #2
0
        public static Route RegisterRoutes(this AreaRegistrationContext context, string url, string[] namespaces)
        {
            Route route = null;

            if (WebConstants.MultiLanguageAreas == MultiLanguageRoutingOptions.Both || WebConstants.MultiLanguageAreas == MultiLanguageRoutingOptions.OnlyLanguageBased)
            {
                route = context.MapRouteWithName(
                    name: $"{context.AreaName}_default_un_LangBased",
                    url: $"{{lang}}/{context.AreaName}/{url}",
                    defaults: new { lang = LangRouteConstraint.DefaultLanguage },
                    constraints: new { lang = new LangRouteConstraint() },
                    namespaces: namespaces
                    );
            }

            if (WebConstants.MultiLanguageAreas == MultiLanguageRoutingOptions.Both || WebConstants.MultiLanguageAreas == MultiLanguageRoutingOptions.None)
            {
                route = context.MapRouteWithName(
                    name: $"{context.AreaName}_default_un",
                    url: $"{context.AreaName}/{url}",
                    namespaces: namespaces
                    );
            }

            return(route);
        }
コード例 #3
0
        public static Route RegisterRoutes(this AreaRegistrationContext context, string name, string url)
        {
            Route route = null;

            if (WebConstants.MultiLanguageAreas == MultiLanguageRoutingOptions.Both || WebConstants.MultiLanguageAreas == MultiLanguageRoutingOptions.OnlyLanguageBased)
            {
                route = context.MapRouteWithName(
                    name: $"{context.AreaName}_{name}_nu_LangBased",
                    url: $"{{lang}}/{context.AreaName}/{url}",
                    defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional, lang = LangRouteConstraint.DefaultLanguage },
                    constraints: new { lang = new LangRouteConstraint() }
                    );
            }

            if (WebConstants.MultiLanguageAreas == MultiLanguageRoutingOptions.Both || WebConstants.MultiLanguageAreas == MultiLanguageRoutingOptions.None)
            {
                route = context.MapRouteWithName(
                    name: $"{context.AreaName}_{name}_nu",
                    url: $"{context.AreaName}/{url}",
                    defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
                    );
            }

            return(route);
        }
コード例 #4
0
        public static void RegisterClientAwareRoutes(this AreaRegistrationContext context, params string[] namespaces)
        {
            if (WebConstants.MultiLanguageClientAwareController == MultiLanguageRoutingOptions.Both || WebConstants.MultiLanguageClientAwareController == MultiLanguageRoutingOptions.OnlyLanguageBased)
            {
                context.MapRouteWithName(
                    name: $"{context.AreaName}_ClientAwareController_Styles_Route_LangBased",
                    url: $"{{lang}}/{context.AreaName}/{{controller}}/{Locust.WebTools.WebConstants.CSS_PROCESSING_ACTION}/{{name}}/{{type}}",
                    defaults: new { action = "css", type = UrlParameter.Optional, lang = LangRouteConstraint.DefaultLanguage },
                    constraints: new { lang = new LangRouteConstraint() },
                    namespaces: namespaces
                    );

                context.MapRouteWithName(
                    name: $"{context.AreaName}_ClientAwareController_Javascript_Route_LangBased",
                    url: $"{{lang}}/{context.AreaName}/{{controller}}/{Locust.WebTools.WebConstants.JS_PROCESSING_ACTION}/{{name}}/{{type}}",
                    defaults: new { action = "js", type = UrlParameter.Optional, lang = LangRouteConstraint.DefaultLanguage },
                    constraints: new { lang = new LangRouteConstraint() },
                    namespaces: namespaces
                    );
            }

            if (WebConstants.MultiLanguageClientAwareController == MultiLanguageRoutingOptions.Both || WebConstants.MultiLanguageClientAwareController == MultiLanguageRoutingOptions.None)
            {
                context.MapRouteWithName(
                    name: $"{context.AreaName}_ClientAwareController_Styles_Route",
                    url: $"{context.AreaName}/{{controller}}/{Locust.WebTools.WebConstants.CSS_PROCESSING_ACTION}/{{name}}/{{type}}",
                    defaults: new { action = "css", type = UrlParameter.Optional },
                    namespaces: namespaces
                    );

                context.MapRouteWithName(
                    name: $"{context.AreaName}_ClientAwareController_Javascript_Route",
                    url: $"{context.AreaName}/{{controller}}/{Locust.WebTools.WebConstants.JS_PROCESSING_ACTION}/{{name}}/{{type}}",
                    defaults: new { action = "js", type = UrlParameter.Optional },
                    namespaces: namespaces
                    );
            }
        }