本文整理汇总了C#中ISettingsManager.GetObjectSettings方法的典型用法代码示例。如果您正苦于以下问题:C# ISettingsManager.GetObjectSettings方法的具体用法?C# ISettingsManager.GetObjectSettings怎么用?C# ISettingsManager.GetObjectSettings使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ISettingsManager
的用法示例。
在下文中一共展示了ISettingsManager.GetObjectSettings方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LoadObjectSettings
protected void LoadObjectSettings(ISettingsManager settingManager, object obj)
{
var haveSettingsObjects = obj.GetFlatListObjectsWithInterface<IHaveSettings>();
foreach (var haveSettingsObject in haveSettingsObjects)
{
var entity = haveSettingsObject as Entity;
if (entity != null && !entity.IsTransient())
{
var storedSettings = settingManager.GetObjectSettings(entity.GetType().Name, entity.Id);
//Merge default settings and stored in db
if (haveSettingsObject.Settings != null)
{
var resultSettings = new List<SettingEntry>();
foreach (var setting in haveSettingsObject.Settings)
{
var storedSetting = storedSettings.FirstOrDefault(x => x.Name == setting.Name);
if (storedSetting != null)
{
resultSettings.Add(storedSetting);
}
else
{
resultSettings.Add(setting);
}
}
haveSettingsObject.Settings = resultSettings;
}
else
{
haveSettingsObject.Settings = storedSettings;
}
}
}
}
示例2: LoadObjectSettings
protected void LoadObjectSettings(ISettingsManager settingManager, object obj)
{
var haveSettingsObjects = obj.GetFlatObjectsListWithInterface<IHaveSettings>();
foreach (var haveSettingsObject in haveSettingsObjects)
{
var entity = haveSettingsObject as Entity;
if (entity != null && !entity.IsTransient())
{
var storedSettings = settingManager.GetObjectSettings(entity.GetType().Name, entity.Id);
// Replace in-memory settings with stored in database
if (haveSettingsObject.Settings != null)
{
var resultSettings = new List<SettingEntry>();
foreach (var setting in haveSettingsObject.Settings)
{
var storedSetting = storedSettings.FirstOrDefault(x => x.Name == setting.Name);
if (storedSetting != null)
{
resultSettings.Add(storedSetting);
}
else
{
setting.Value = setting.DefaultValue;
resultSettings.Add(setting);
}
}
haveSettingsObject.Settings = resultSettings;
}
else
{
haveSettingsObject.Settings = storedSettings;
}
}
}
}