Skip to content

Instantly share code, notes, and snippets.

@trnktms
Last active February 16, 2021 10:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save trnktms/c1d357b4dc2755d2cfdde43d5fb28a52 to your computer and use it in GitHub Desktop.
Save trnktms/c1d357b4dc2755d2cfdde43d5fb28a52 to your computer and use it in GitHub Desktop.
public static class SettingsUtil
{
// 1. Instead of Factory.GetConfigNode(customConfigNode)
public XmlNode GetConfigNode(string customConfigNode)
{
return ConfigReader.GetConfiguration().SelectSingleNode($"sitecore/{customConfigNode}");
}
// 2. Instead of Settings.GetSetting(name)
public string GetSetting(string name)
{
var node = ConfigReader.GetConfiguration().SelectSingleNode($"sitecore/settings/setting[@name='{name}']");
if (node == null)
{
return null;
}
return node.Attributes["value"].Value;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment