Example #1
0
        private void Randomize()
        {
            List <RedditPost> posts = PostsToFilter.ToList();
            Random            r     = new Random(Vm.RandomizeSeed);

            int curr = posts.Count;

            while (curr > 1)
            {
                curr--;
                int        toSwap = r.Next(curr + 1);
                RedditPost value  = posts[toSwap];
                posts[toSwap] = posts[curr];
                posts[curr]   = value;
            }

            PostsToFilter = posts.AsEnumerable();
        }
Example #2
0
        private void ContentTypeFilter()
        {
            List <RedditPost>  posts = PostsToFilter.ToList();
            List <ContentType> types = Enum.GetValues(typeof(ContentType)).Cast <ContentType>().ToList();

            for (int i = posts.Count - 1; i >= 0; i--)
            {
                RedditPost  post = posts[i];
                ContentType type = post.GetContentType();

                for (int j = 0; j < types.Count; j++)
                {
                    bool isWhitelisted = Vm.ContentTypes[j];

                    if (!isWhitelisted && types[j] == type)
                    {
                        posts.RemoveAt(i);
                    }
                }
            }

            PostsToFilter = posts.AsEnumerable();
        }