/// <summary> /// Initializes the provider instance with data from <see cref="SingleLocalization"/>. /// </summary> /// <param name="topologyProvider">The topology provider containing the required information /// about the localizable controllers and actions.</param> /// <exception cref="InvalidOperationException"> /// More than one controller's name matches with the localization.-or- /// More than one action's name matches with the localization within the same controller. /// </exception> public override void Init(IMvcTopologyProvider topologyProvider) { var topology = topologyProvider.GetMvcTopology(); foreach (var controllerInfo in topology.Controllers.Values) { string localizedControllerName = GetLocalizationForController(controllerInfo); if (SingleLocalization.ControllersByLocalizedName.ContainsKey(localizedControllerName)) { throw new InvalidOperationException( $"There are more than one controller with localized the name of '{localizedControllerName}'."); } var controllerLocalization = new ControllerLocalization() { OriginalName = controllerInfo.Name, LocalizedName = localizedControllerName }; SingleLocalization.ControllersByOriginalName.Add(controllerInfo.Name, controllerLocalization); SingleLocalization.ControllersByLocalizedName.Add(localizedControllerName, controllerLocalization); AddActionLocalizations(controllerInfo, controllerLocalization); } }
/// <summary> /// Caches the <see cref="MvcTopology"/> instance created by <paramref name="topologyProvider"/> /// into the <see cref="MvcTopologyCache"/> property. /// </summary> /// <param name="topologyProvider">The topology provider containing the required information /// about the localizable controllers and actions.</param> public override void Init(IMvcTopologyProvider topologyProvider) { MvcTopologyCache = topologyProvider.GetMvcTopology(); }