コード例 #1
0
        private static List <Comment> RemoveTotallyBlacklisted(List <Comment> comments)
        {
            List <Comment> result = comments.ToList();

            foreach (Comment comment in comments)
            {
                BlacklistLevel level = GetBlacklistLevelForUser(comment.AuthorName);
                if (level == BlacklistLevel.OnlyKeywordReplies)
                {
                    result.Remove(comment);
                }
            }

            return(result);
        }
コード例 #2
0
        public static Dictionary <string, BlacklistLevel> GetBlacklist()
        {
            if (!File.Exists(blacklistedPath))
            {
                File.Create(blacklistedPath).Close();
            }

            Dictionary <string, BlacklistLevel> result = new Dictionary <string, BlacklistLevel>();

            List <string> lines = File.ReadAllLines(blacklistedPath).ToList();

            foreach (string line in lines)
            {
                string         username  = line.Split(',')[0];
                BlacklistLevel blacklist = (BlacklistLevel)Convert.ToInt32(line.Split(',')[1]);
                result.Add(username, blacklist);
            }

            return(result);
        }