コード例 #1
0
        public RouteTranslator AddTranslation(string url, string culture, LocalizationCollectionRoute route)
        {
            if (string.IsNullOrEmpty(culture))
            {
                throw new ArgumentNullException("culture");
            }

            if (route == null)
            {
                throw new ArgumentNullException("route");
            }

            if (Configuration.ValidateCulture &&
                Configuration.AcceptedCultures.All(
                    acceptedCulture => !string.Equals(acceptedCulture, culture, StringComparison.CurrentCultureIgnoreCase)))
            {
                throw new InvalidOperationException(string.Format("AcceptedCultures does not contain culture '{0}'.", culture));
            }

            route.AddTranslation(TransformUrl(url, culture, route), culture);

            if (Configuration.AttributeRouteProcessing == AttributeRouteProcessing.AddAsNeutralRouteAndReplaceByFirstTranslation)
            {
                // Remove neutral route
                route.RemoveTranslation(string.Empty);
            }

            return(this);
        }
コード例 #2
0
        public RouteTranslator AddNeutralTranslation(LocalizationCollectionRoute route)
        {
            route.AddTranslation(route.Url(), string.Empty);

            return(this);
        }