/// <summary> /// Parses the view path and title. /// </summary> public static void ParsePath(View viewEntity, out string[] pathParts, out string viewTitle) { if (viewEntity == null) { throw new ArgumentNullException(nameof(viewEntity)); } string GetLastPart(string[] parts) { return(parts.Length > 0 ? parts[parts.Length - 1] : ""); } if (!string.IsNullOrEmpty(viewEntity.Title) && viewEntity.Title.IndexOfAny(PathSeparator) >= 0) { pathParts = viewEntity.Title.Split(PathSeparator, StringSplitOptions.RemoveEmptyEntries); viewTitle = GetLastPart(pathParts); } else if (!string.IsNullOrEmpty(viewEntity.Path)) { pathParts = viewEntity.Path.Split(PathSeparator, StringSplitOptions.RemoveEmptyEntries); viewTitle = ScadaUtils.FirstNonEmpty(viewEntity.Title, GetLastPart(pathParts)) ?? ""; } else if (!string.IsNullOrEmpty(viewEntity.Title)) { pathParts = new string[] { viewEntity.Title }; viewTitle = viewEntity.Title; } else { pathParts = Array.Empty <string>(); viewTitle = ""; } }
private IActionResult RedirectToStartPage(string returnUrl) { UserConfig userConfig = webContext.PluginHolder.GetUserConfig(User.GetUserID()); string url = Url.Content(ScadaUtils.FirstNonEmpty( returnUrl, userConfig?.StartPage, webContext.AppConfig.GeneralOptions.DefaultStartPage, WebPath.DefaultStartPage.PrependTilda())); return(LocalRedirect(url)); }
/// <summary> /// Updates the application culture according to the configuration. /// </summary> private void UpdateCulture(WebConfig webConfig) { string cultureName = ScadaUtils.FirstNonEmpty( InstanceConfig.Culture, webConfig.GeneralOptions.DefaultCulture, Locale.DefaultCulture.Name); if (Locale.Culture.Name != cultureName) { Locale.SetCulture(cultureName); LocalizeApp(); } }
public override string ToString() => ScadaUtils.FirstNonEmpty(En, Ru);