allow searching for setting by ID instead of name - names are deprecated

This commit is contained in:
Michael Becker 2022-09-13 09:42:16 -04:00
parent eeda385dcf
commit 13da008241
No known key found for this signature in database
GPG Key ID: DA394832305DA332
2 changed files with 52 additions and 0 deletions

View File

@ -69,6 +69,23 @@ namespace MBS.Framework.Settings
}
return null;
}
public Setting FindSetting(Guid id)
{
foreach (Setting s in Options)
{
if (s is GroupSetting)
{
Setting r = (s as GroupSetting).FindSetting(id);
if (r != null) return r;
}
else
{
if (s.ID == id)
return s;
}
}
return null;
}
public override object Clone()
{

View File

@ -74,6 +74,26 @@ namespace MBS.Framework
}
return null;
}
public Setting FindSetting(Guid id)
{
foreach (SettingsGroup sg in SettingsGroups)
{
foreach (Setting s in sg.Settings)
{
if (s is GroupSetting)
{
Setting r = (s as GroupSetting).FindSetting(id);
if (r != null) return r;
}
else
{
if (s.ID == id)
return s;
}
}
}
return null;
}
protected virtual void InitializeInternal()
{
@ -119,5 +139,20 @@ namespace MBS.Framework
other.SettingsGroups.Add(group.Clone() as SettingsGroup);
}
}
public SettingsProvider Clone(string settingsGroupsPrefix)
{
CustomSettingsProvider prov = new CustomSettingsProvider();
foreach (SettingsGroup sg in this.SettingsGroups)
{
SettingsGroup sg2 = sg.Clone() as SettingsGroup;
string[] szpath = new string[sg.Path.Length + 1];
Array.Copy(sg.Path, 0, szpath, 1, sg.Path.Length);
szpath[0] = settingsGroupsPrefix;
sg2.Path = szpath;
prov.SettingsGroups.Add(sg2);
}
return prov;
}
}
}