mirror of
https://github.com/chylex/TweetDuck.git
synced 2025-04-29 11:34:13 +02:00
* Switch to .NET Framework 4.7.2 & C# 8.0, update libraries * Add TweetLib.Core project targeting .NET Standard 2.0 * Enable reference nullability checks for TweetLib.Core * Move a bunch of utility classes into TweetLib.Core & refactor * Partially move TweetDuck plugin & update system to TweetLib.Core * Move some constants and CultureInfo setup to TweetLib.Core * Move some configuration classes to TweetLib.Core * Minor refactoring and warning suppression * Add App to TweetLib.Core * Add IAppErrorHandler w/ implementation * Continue moving config, plugin, and update classes to TweetLib.Core * Fix a few nullability checks * Update installers to check for .NET Framework 4.7.2
52 lines
1.7 KiB
C#
52 lines
1.7 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using TweetLib.Core.Features.Configuration;
|
|
using TweetLib.Core.Features.Plugins;
|
|
using TweetLib.Core.Features.Plugins.Config;
|
|
using TweetLib.Core.Features.Plugins.Events;
|
|
|
|
namespace TweetDuck.Configuration{
|
|
sealed class PluginConfig : BaseConfig, IPluginConfig{
|
|
private static readonly string[] DefaultDisabled = {
|
|
"official/clear-columns",
|
|
"official/reply-account"
|
|
};
|
|
|
|
// CONFIGURATION DATA
|
|
|
|
private readonly HashSet<string> disabled = new HashSet<string>(DefaultDisabled);
|
|
|
|
// EVENTS
|
|
|
|
public event EventHandler<PluginChangedStateEventArgs> PluginChangedState;
|
|
|
|
// END OF CONFIG
|
|
|
|
public PluginConfig(IConfigManager configManager) : base(configManager){}
|
|
|
|
protected override BaseConfig ConstructWithDefaults(IConfigManager configManager){
|
|
return new PluginConfig(configManager);
|
|
}
|
|
|
|
// INTERFACE IMPLEMENTATION
|
|
|
|
IEnumerable<string> IPluginConfig.DisabledPlugins => disabled;
|
|
|
|
void IPluginConfig.Reset(IEnumerable<string> newDisabledPlugins){
|
|
disabled.Clear();
|
|
disabled.UnionWith(newDisabledPlugins);
|
|
}
|
|
|
|
public void SetEnabled(Plugin plugin, bool enabled){
|
|
if ((enabled && disabled.Remove(plugin.Identifier)) || (!enabled && disabled.Add(plugin.Identifier))){
|
|
PluginChangedState?.Invoke(this, new PluginChangedStateEventArgs(plugin, enabled));
|
|
Save();
|
|
}
|
|
}
|
|
|
|
public bool IsEnabled(Plugin plugin){
|
|
return !disabled.Contains(plugin.Identifier);
|
|
}
|
|
}
|
|
}
|