2010-07-15, 01:17 AM
Here's an example of my own Save() function that does that:
"_sh" being NUtility.SettingsHelper.GetInstance()
The end result in config.xml is:
Code:
public void Save()
{
XmlNode node;
#region Plugin Global Settings
if ((node = _sh.GetSettingsNode("/Settings/PluginSettings/StreamIt")) == null)
{
_sh.GetSettingsNode("/Settings/PluginSettings").AppendChild(_sh.GetBackingDocument().CreateNode("element", "StreamIt", ""));
}
if ((node = _sh.GetSettingsNode("/Settings/PluginSettings/StreamIt/Netflix")) == null)
{
_sh.GetSettingsNode("/Settings/PluginSettings/StreamIt").AppendChild(_sh.GetBackingDocument().CreateNode("element", "Netflix", ""));
}
#endregion
#region Last Selected Genre
if ((node = _sh.GetSettingsNode("/Settings/PluginSettings/StreamIt/Netflix/LastGenre")) == null)
{
_sh.GetSettingsNode("/Settings/PluginSettings/StreamIt/Netflix").AppendChild(_sh.GetBackingDocument().CreateNode("element", "LastGenre", ""));
_sh.GetSettingsNode("/Settings/PluginSettings/StreamIt/Netflix/LastGenre").InnerText = _LastGenre;
}
else _sh.SetSetting("/Settings/PluginSettings/StreamIt/Netflix/LastGenre", _LastGenre);
#endregion
#region Player Kiosk Mode
if ((node = _sh.GetSettingsNode("/Settings/PluginSettings/StreamIt/Netflix/PlayerKioskMode")) == null)
{
_sh.GetSettingsNode("/Settings/PluginSettings/StreamIt/Netflix").AppendChild(_sh.GetBackingDocument().CreateNode("element", "PlayerKioskMode", ""));
_sh.GetSettingsNode("/Settings/PluginSettings/StreamIt/Netflix/PlayerKioskMode").InnerText = _playerKioskMode.ToString().ToLowerInvariant();
}
else _sh.SetSetting("/Settings/PluginSettings/StreamIt/Netflix/PlayerKioskMode", _playerKioskMode);
#endregion
#region Last View Mode
if ((node = _sh.GetSettingsNode("/Settings/PluginSettings/StreamIt/Netflix/LastViewMode")) == null)
{
_sh.GetSettingsNode("/Settings/PluginSettings/StreamIt/Netflix").AppendChild(_sh.GetBackingDocument().CreateNode("element", "LastViewMode", ""));
_sh.GetSettingsNode("/Settings/PluginSettings/StreamIt/Netflix/LastViewMode").InnerText = _viewMode;
}
else _sh.SetSetting("/Settings/PluginSettings/StreamIt/Netflix/LastViewMode", _viewMode);
#endregion
#region Use BoxArt Reflections
if ((node = _sh.GetSettingsNode("/Settings/PluginSettings/StreamIt/Netflix/BoxArtReflections")) == null)
{
_sh.GetSettingsNode("/Settings/PluginSettings/StreamIt/Netflix").AppendChild(_sh.GetBackingDocument().CreateNode("element", "BoxArtReflections", ""));
_sh.GetSettingsNode("/Settings/PluginSettings/StreamIt/Netflix/BoxArtReflections").InnerText = _useReflections.ToString().ToLowerInvariant();
}
else _sh.SetSetting("/Settings/PluginSettings/StreamIt/Netflix/BoxArtReflections", _useReflections);
#endregion
#region BoxArt Reflection Starting Alpha
if ((node = _sh.GetSettingsNode("/Settings/PluginSettings/StreamIt/Netflix/ReflectionAlpha")) == null)
{
_sh.GetSettingsNode("/Settings/PluginSettings/StreamIt/Netflix").AppendChild(_sh.GetBackingDocument().CreateNode("element", "ReflectionAlpha", ""));
_sh.GetSettingsNode("/Settings/PluginSettings/StreamIt/Netflix/ReflectionAlpha").InnerText = _reflectionStartingAlpha.ToString();
}
else _sh.SetSetting("/Settings/PluginSettings/StreamIt/Netflix/ReflectionAlpha", _reflectionStartingAlpha);
#endregion
#region BoxArt Reflection Percentage
if ((node = _sh.GetSettingsNode("/Settings/PluginSettings/StreamIt/Netflix/ReflectionHeight")) == null)
{
_sh.GetSettingsNode("/Settings/PluginSettings/StreamIt/Netflix").AppendChild(_sh.GetBackingDocument().CreateNode("element", "ReflectionHeight", ""));
_sh.GetSettingsNode("/Settings/PluginSettings/StreamIt/Netflix/ReflectionHeight").InnerText = _reflectionPercent.ToString().ToLowerInvariant();
}
else _sh.SetSetting("/Settings/PluginSettings/StreamIt/Netflix/ReflectionHeight", _reflectionPercent);
#endregion
#region Ending Soon Days
if ((node = _sh.GetSettingsNode("/Settings/PluginSettings/StreamIt/Netflix/EndingSoonDays")) == null)
{
_sh.GetSettingsNode("/Settings/PluginSettings/StreamIt/Netflix").AppendChild(_sh.GetBackingDocument().CreateNode("element", "EndingSoonDays", ""));
_sh.GetSettingsNode("/Settings/PluginSettings/StreamIt/Netflix/EndingSoonDays").InnerText = _endingSoonDays.ToString();
}
else _sh.SetSetting("/Settings/PluginSettings/StreamIt/Netflix/EndingSoonDays", _endingSoonDays);
#endregion
#region Ending Soon Days
if ((node = _sh.GetSettingsNode("/Settings/PluginSettings/StreamIt/Netflix/ShowOnlyAvailable")) == null)
{
_sh.GetSettingsNode("/Settings/PluginSettings/StreamIt/Netflix").AppendChild(_sh.GetBackingDocument().CreateNode("element", "ShowOnlyAvailable", ""));
_sh.GetSettingsNode("/Settings/PluginSettings/StreamIt/Netflix/ShowOnlyAvailable").InnerText = _showOnlyAvailable.ToString().ToLowerInvariant();
}
else _sh.SetSetting("/Settings/PluginSettings/StreamIt/Netflix/ShowOnlyAvailable", _showOnlyAvailable);
#endregion
_sh.Save();
}
"_sh" being NUtility.SettingsHelper.GetInstance()
The end result in config.xml is:
Code:
<PluginSettings>
<StreamIt>
<Netflix>
<LastGenre>All Movies</LastGenre>
<PlayerKioskMode>false</PlayerKioskMode>
<LastViewMode>LIST</LastViewMode>
<BoxArtReflections>true</BoxArtReflections>
<ReflectionAlpha>150</ReflectionAlpha>
<ReflectionHeight>45</ReflectionHeight>
<EndingSoonDays>30</EndingSoonDays>
<ShowOnlyAvailable>true</ShowOnlyAvailable>
</Netflix>
</StreamIt>
</PluginSettings>