Skip to content

Instantly share code, notes, and snippets.

@trnktms

trnktms/SettingsUtil.cs

Last active Feb 16, 2021
Embed
What would you like to do?
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