Пример #1
0
        public void FitlerXamarinTitleAndCategoryTest()
        {
            var item = new SyndicationItem("some blog post about xamarin android stuff", "whatever", new Uri("http://derp.org"));

            item.Categories.Add(new SyndicationCategory("xamarin"));

            var ok = item.ApplyDefaultFilter();

            Assert.True(ok);

            item = new SyndicationItem("some blog post about java android stuff", "whatever", new Uri("http://derp.org"));
            item.Categories.Add(new SyndicationCategory("java"));

            ok = item.ApplyDefaultFilter();
            Assert.False(ok);

            item = new SyndicationItem("some blog post about java android stuff", "whatever", new Uri("http://derp.org"));
            item.Categories.Add(new SyndicationCategory("xamarin"));

            ok = item.ApplyDefaultFilter();
            Assert.True(ok);

            item = new SyndicationItem("some blog post about xamarin android stuff", "whatever", new Uri("http://derp.org"));
            item.Categories.Add(new SyndicationCategory("java"));

            ok = item.ApplyDefaultFilter();
            Assert.True(ok);
        }
Пример #2
0
        public void FilterXamarinCategoryTest()
        {
            var item = new SyndicationItem();

            item.Categories.Add(new SyndicationCategory("android"));
            item.Categories.Add(new SyndicationCategory("ios"));
            item.Categories.Add(new SyndicationCategory("xamarin"));

            var ok = item.ApplyDefaultFilter();

            Assert.True(ok);

            item.Categories.RemoveAt(2);

            ok = item.ApplyDefaultFilter();
            Assert.False(ok);
        }
Пример #3
0
        public bool Filter(SyndicationItem item)
        {
            // if my blog has keyword, disableplanetxamarin, Prohibit publishing to on planetxamarin
            if (item.Title.Text.ToLowerInvariant().Contains("disableplanetxamarin") ||
                (item.Categories?.Any(c => c.Name.ToLowerInvariant().Equals("disableplanetxamarin")) ?? false))
            {
                return(false);
            }

            return(item.ApplyDefaultFilter());
        }
Пример #4
0
        public void FilterXamarinTitleTest()
        {
            var item = new SyndicationItem("some blog post about xamarin android stuff", "whatever", new Uri("http://derp.org"));

            var ok = item.ApplyDefaultFilter();

            Assert.True(ok);

            item = new SyndicationItem("some blog post about native android stuff", "whatever", new Uri("http://derp.org"));

            ok = item.ApplyDefaultFilter();
            Assert.False(ok);
        }
Пример #5
0
        public bool Filter(SyndicationItem item)
        {
            if (item.Title.Text.StartsWith("daily links", StringComparison.InvariantCultureIgnoreCase))
            {
                return(false);
            }

            if (item.Categories?.Any(c => c.Name.ToLowerInvariant().Equals("dailylinks")) ?? false)
            {
                return(false);
            }

            return(item.ApplyDefaultFilter());
        }
Пример #6
0
        private static bool WrappedFilter(SyndicationItem item, Func <SyndicationItem, bool> filterFunc)
        {
            try
            {
                return(filterFunc(item));
            }
            catch (NullReferenceException)
            {
                // the authors' filter is derped
                // try some sane defaults

                return(item.ApplyDefaultFilter());
            }
        }
Пример #7
0
        private static bool TryFilter(SyndicationItem item, Func <SyndicationItem, bool> filterFunc)
        {
            try
            {
                if (filterFunc != null)
                {
                    return(filterFunc(item));
                }
            }
            catch (Exception)
            {
            }

            // the authors' filter is derped or has no filter
            // try some sane defaults
            return(item.ApplyDefaultFilter());
        }