コード例 #1
0
ファイル: IBlackWhiteList.cs プロジェクト: Ytrog/RssBandit
        public static void AddBlacklist(IBlacklist blackList, string content)
        {
            if (blacklists.ContainsKey(blackList.GetType().Name) == false)
            {
                blackList.Initialize(content);
                blackList.UpdateBlacklist();
                blacklists.Add(blackList.GetType().Name, blackList);
            }
            else
            {
                // update the blacklist
                IBlacklist refr = blacklists[blackList.GetType().Name] as IBlacklist;
                refr.Initialize(content);
                ListUpdateState updateState = refr.UpdateBlacklist();

                if (updateState == ListUpdateState.Failed)
                {
                    throw new InvalidOperationException(blackList + " could not be updated.");
                }
            }
        }
コード例 #2
0
        public async Task AddPluginAsync(IBlacklist blacklistPlugin)
        {
            this.Logger.LogInfo("Initializes blacklist plugin \"" + blacklistPlugin.GetType().FullName + "\".");
            if (blacklistPlugin is IInitializable initializable)
            {
                await initializable.InitializeAsync();
            }

            BlacklistCollection collection;

            if (this.plugins.ContainsKey(typeof(IBlacklist)))
            {
                collection = (BlacklistCollection)this.plugins[typeof(IBlacklist)];
            }
            else
            {
                this.plugins.Add(typeof(IBlacklist), collection = new BlacklistCollection());
            }

            collection.Add(blacklistPlugin);

            this.Logger.LogInfo("Plugin \"" + blacklistPlugin.GetType().FullName + "\" ready to use.");
        }