home
products
contribute
download
documentation
forum
Home
Forums
New posts
Search forums
What's new
New posts
All posts
Latest activity
Members
Registered members
Current visitors
Donate
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Search titles only
By:
Menu
Log in
Register
Navigation
Install the app
Install
More options
Contact us
Close Menu
Forums
MediaPortal 2
Testing Area
Development Snapshots
MediaPortal 2 development snapshot (2014-12-19)
Contact us
RSS
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="osre" data-source="post: 1116610" data-attributes="member: 150866"><p>I made my change at a central point, but I think I did not fully take into account, that there is not a global and a user file for all setting classes.</p><p>My change looks like this:</p><p>\MediaPortal\Source\Core\MediaPortal.Common\Services\Settings\SettingsManager.cs:101</p><p>[CODE=C#] protected object LoadSettingsObject(Type settingsType)</p><p> {</p><p> SettingsFileHandler globalHandler = new SettingsFileHandler(GetGlobalFilePath(settingsType));</p><p> SettingsFileHandler userHandler = new SettingsFileHandler(GetUserFilePath(settingsType));</p><p> try</p><p> {</p><p> globalHandler.Load();</p><p> }</p><p> catch (Exception e)</p><p> {</p><p> ServiceRegistration.Get<ILogger>().Error("SettingsManager: Error loading global settings file for setting type '{0}'... Will clear this settings file.", e, settingsType.Name);</p><p> globalHandler.Clear();</p><p> RemoveSettingsData(settingsType, false, true);</p><p> }</p><p> try</p><p> {</p><p> userHandler.Load();</p><p> }</p><p> catch (Exception e)</p><p> {</p><p> ServiceRegistration.Get<ILogger>().Error("SettingsManager: Error loading user settings file for setting type '{0}'... Will clear this settings file.", e, settingsType.Name);</p><p> userHandler.Clear();</p><p> RemoveSettingsData(settingsType, true, false);</p><p> }</p><p> try</p><p> {</p><p> object result = Activator.CreateInstance(settingsType);</p><p> foreach (PropertyInfo property in result.GetType().GetProperties())</p><p> {</p><p> SettingAttribute att = GetSettingAttribute(property);</p><p> if (att == null) continue;</p><p> SettingsFileHandler s = (att.SettingScope == SettingScope.Global ? globalHandler : userHandler);</p><p> try</p><p> {</p><p> object value = s.GetValue(property.Name, property.PropertyType);</p><p> if (value == null)</p><p> if (att.HasDefault)</p><p> value = att.DefaultValue;</p><p> else</p><p> continue;</p><p> property.SetValue(result, value, null);</p><p> }</p><p> catch (Exception e)</p><p> {</p><p> ServiceRegistration.Get<ILogger>().Error("SettingsManager: Error setting property '{0}' in settings of type '{1}'" +</p><p> (att.HasDefault ? ", using default value" : string.Empty), e, property.Name, settingsType.Name);</p><p> if (att.HasDefault)</p><p> property.SetValue(result, att.DefaultValue, null);</p><p> }</p><p> }</p><p> /* my modification, but I guess '||' should be replaced by an '&&'</p><p> if (!File.Exists(globalHandler.FilePath) || !File.Exists(userHandler.FilePath))</p><p> {</p><p> SaveSettingsObject(result);</p><p> }*/</p><p> return result;</p><p> }</p><p> catch (Exception e)</p><p> {</p><p> ServiceRegistration.Get<ILogger>().Error("SettingsManager: Error loading settings of type '{0}'", e, settingsType.Name);</p><p> return null;</p><p> }</p><p> }[/CODE]</p><p>About the no sound issue: may be I hit some keyboard short cut.</p></blockquote><p></p>
[QUOTE="osre, post: 1116610, member: 150866"] I made my change at a central point, but I think I did not fully take into account, that there is not a global and a user file for all setting classes. My change looks like this: \MediaPortal\Source\Core\MediaPortal.Common\Services\Settings\SettingsManager.cs:101 [CODE=C#] protected object LoadSettingsObject(Type settingsType) { SettingsFileHandler globalHandler = new SettingsFileHandler(GetGlobalFilePath(settingsType)); SettingsFileHandler userHandler = new SettingsFileHandler(GetUserFilePath(settingsType)); try { globalHandler.Load(); } catch (Exception e) { ServiceRegistration.Get<ILogger>().Error("SettingsManager: Error loading global settings file for setting type '{0}'... Will clear this settings file.", e, settingsType.Name); globalHandler.Clear(); RemoveSettingsData(settingsType, false, true); } try { userHandler.Load(); } catch (Exception e) { ServiceRegistration.Get<ILogger>().Error("SettingsManager: Error loading user settings file for setting type '{0}'... Will clear this settings file.", e, settingsType.Name); userHandler.Clear(); RemoveSettingsData(settingsType, true, false); } try { object result = Activator.CreateInstance(settingsType); foreach (PropertyInfo property in result.GetType().GetProperties()) { SettingAttribute att = GetSettingAttribute(property); if (att == null) continue; SettingsFileHandler s = (att.SettingScope == SettingScope.Global ? globalHandler : userHandler); try { object value = s.GetValue(property.Name, property.PropertyType); if (value == null) if (att.HasDefault) value = att.DefaultValue; else continue; property.SetValue(result, value, null); } catch (Exception e) { ServiceRegistration.Get<ILogger>().Error("SettingsManager: Error setting property '{0}' in settings of type '{1}'" + (att.HasDefault ? ", using default value" : string.Empty), e, property.Name, settingsType.Name); if (att.HasDefault) property.SetValue(result, att.DefaultValue, null); } } /* my modification, but I guess '||' should be replaced by an '&&' if (!File.Exists(globalHandler.FilePath) || !File.Exists(userHandler.FilePath)) { SaveSettingsObject(result); }*/ return result; } catch (Exception e) { ServiceRegistration.Get<ILogger>().Error("SettingsManager: Error loading settings of type '{0}'", e, settingsType.Name); return null; } }[/CODE] About the no sound issue: may be I hit some keyboard short cut. [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
MediaPortal 2
Testing Area
Development Snapshots
MediaPortal 2 development snapshot (2014-12-19)
Contact us
RSS
Top
Bottom