<commit_before>﻿using System;
using System.Collections.Generic;
using TweetDck.Plugins.Events;

namespace TweetDck.Plugins{
    [Serializable]
    class PluginConfig{
        [field:NonSerialized]
        public event EventHandler<PluginChangedStateEventArgs> PluginChangedState;

        public IEnumerable<string> DisabledPlugins{
            get{
                return Disabled;
            }
        }

        public bool AnyDisabled{
            get{
                return Disabled.Count > 0;
            }
        }

        private readonly HashSet<string> Disabled = new HashSet<string>();

        public void SetEnabled(Plugin plugin, bool enabled){
            if ((enabled && Disabled.Remove(plugin.Identifier)) || (!enabled && Disabled.Add(plugin.Identifier))){
                if (PluginChangedState != null){
                    PluginChangedState(this, new PluginChangedStateEventArgs(plugin, enabled));
                }
            }
        }

        public bool IsEnabled(Plugin plugin){
            return !Disabled.Contains(plugin.Identifier) && plugin.CanRun;
        }
    }
}<commit_msg>Seal PluginConfig and add a method to disable official plugins from config<commit_after>﻿using System;
using System.Collections.Generic;
using TweetDck.Plugins.Events;

namespace TweetDck.Plugins{
    [Serializable]
    sealed class PluginConfig{
        [field:NonSerialized]
        public event EventHandler<PluginChangedStateEventArgs> PluginChangedState;

        public IEnumerable<string> DisabledPlugins{
            get{
                return Disabled;
            }
        }

        public bool AnyDisabled{
            get{
                return Disabled.Count > 0;
            }
        }

        private readonly HashSet<string> Disabled = new HashSet<string>();

        public void SetEnabled(Plugin plugin, bool enabled){
            if ((enabled && Disabled.Remove(plugin.Identifier)) || (!enabled && Disabled.Add(plugin.Identifier))){
                if (PluginChangedState != null){
                    PluginChangedState(this, new PluginChangedStateEventArgs(plugin, enabled));
                }
            }
        }

        public bool IsEnabled(Plugin plugin){
            return !Disabled.Contains(plugin.Identifier) && plugin.CanRun;
        }

        public void DisableOfficialFromConfig(string pluginName){
            Disabled.Add("official/"+pluginName);
        }
    }
}
{'fraction_non_alphanumeric': 0.08735063864853729, 'fraction_numerical': 0.0008240626287597857, 'mean_word_length': 2.1288659793814433, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4702866', 'n_tokens_mistral': 617, 'n_tokens_neox': 581, 'n_words': 137}