Merge pull request #4339 from BaronGreenback/PluginConfigSave

Making default Plugin configurations accessible when developing.
pull/4486/head
Joshua M. Boniface 4 years ago committed by GitHub
commit d2cef78db3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -247,23 +247,34 @@ namespace MediaBrowser.Common.Plugins
} }
catch catch
{ {
return (TConfigurationType)Activator.CreateInstance(typeof(TConfigurationType)); var config = (TConfigurationType)Activator.CreateInstance(typeof(TConfigurationType));
SaveConfiguration(config);
return config;
} }
} }
/// <summary> /// <summary>
/// Saves the current configuration to the file system. /// Saves the current configuration to the file system.
/// </summary> /// </summary>
public virtual void SaveConfiguration() /// <param name="config">Configuration to save.</param>
public virtual void SaveConfiguration(TConfigurationType config)
{ {
lock (_configurationSaveLock) lock (_configurationSaveLock)
{ {
_directoryCreateFn(Path.GetDirectoryName(ConfigurationFilePath)); _directoryCreateFn(Path.GetDirectoryName(ConfigurationFilePath));
XmlSerializer.SerializeToFile(Configuration, ConfigurationFilePath); XmlSerializer.SerializeToFile(config, ConfigurationFilePath);
} }
} }
/// <summary>
/// Saves the current configuration to the file system.
/// </summary>
public virtual void SaveConfiguration()
{
SaveConfiguration(Configuration);
}
/// <inheritdoc /> /// <inheritdoc />
public virtual void UpdateConfiguration(BasePluginConfiguration configuration) public virtual void UpdateConfiguration(BasePluginConfiguration configuration)
{ {
@ -274,7 +285,7 @@ namespace MediaBrowser.Common.Plugins
Configuration = (TConfigurationType)configuration; Configuration = (TConfigurationType)configuration;
SaveConfiguration(); SaveConfiguration(Configuration);
ConfigurationChanged?.Invoke(this, configuration); ConfigurationChanged?.Invoke(this, configuration);
} }

Loading…
Cancel
Save