// ================================================================================= Settings API (STATIC) /// <summary> /// Loads a settings content with a specified name (or relative path) from the Settings folder. /// </summary> /// <typeparam name="T">The settings type.</typeparam> /// <param name="settingsName">Name or relative path of the settings content.</param> /// <param name="contextPath">The content where the search for the setting will start.</param> /// <returns>Strongly typed settings content or null.</returns> public static T GetSettingsByName <T>(string settingsName, string contextPath) where T : Settings { if (string.IsNullOrEmpty(settingsName)) { throw new ArgumentNullException("settingsName"); } return((T)SettingsCache.GetSettingsByName <T>(settingsName, contextPath) ?? Node.Load <T>(RepositoryPath.Combine(SETTINGSCONTAINERPATH, settingsName + "." + EXTENSION))); }
// ================================================================================= Settings API (STATIC) /// <summary> /// Loads a settings content with a specified name (or relative path) from the Settings folder. /// </summary> /// <typeparam name="T">The settings type.</typeparam> /// <param name="settingsName">Name or relative path of the settings content.</param> /// <param name="contextPath">The content where the search for the setting will start.</param> /// <returns>Strongly typed settings content or null.</returns> public static T GetSettingsByName <T>(string settingsName, string contextPath) where T : Settings { if (string.IsNullOrEmpty(settingsName)) { throw new ArgumentNullException(nameof(settingsName)); } try { return(SettingsCache.GetSettingsByName <T>(settingsName, contextPath) ?? Node.Load <T>(RepositoryPath.Combine(SETTINGSCONTAINERPATH, settingsName + "." + EXTENSION))); } catch (Exception ex) { SnTrace.System.WriteError($"Error loading setting: {settingsName}. {ex.Message}"); } return(null); }