Example #1
0
        public static int CompareById(NewsListItem item1, NewsListItem item2)
        {
            var data1 = item1.DataContext.Id;
            var data2 = item2.DataContext.Id;

            return(data1.CompareTo(data2));
        }
Example #2
0
        public static int CompareByCreatedOn(NewsListItem item1, NewsListItem item2)
        {
            var data1 = item1.DataContext.CreatedOn;
            var data2 = item2.DataContext.CreatedOn;

            return(data1.CompareTo(data2));
        }
Example #3
0
        public static int CompareByTitle(NewsListItem item1, NewsListItem item2)
        {
            var data1 = item1.DataContext.Title;
            var data2 = item2.DataContext.Title;

            return(string.Compare(data1, data2));
        }
Example #4
0
        private bool TestItem(NewsListItem item, NewsSearchOptions search)
        {
            var news = item.DataContext;

            if (news.Title.Contains(search.Text))
            {
                return(true);
            }
            int id;

            if (int.TryParse(search.Text, NumberStyles.Integer, CultureInfo.InvariantCulture, out id))
            {
                if (news.Id == id)
                {
                    return(true);
                }
            }
            return(false);
        }
Example #5
0
        public static int CompareByAuthor(NewsListItem item1, NewsListItem item2)
        {
            var data1 = item1.DataContext.Author;
            var data2 = item2.DataContext.Author;

            if (data1 == data2)
            {
                return(0);
            }
            if (data1 == null)
            {
                return(1);
            }
            else if (data2 == null)
            {
                return(-1);
            }
            return(string.Compare(data1.Name, data2.Name));
        }