コード例 #1
0
ファイル: GKListItemTests.cs プロジェクト: subratb/GEDKeeper
        public void Test_Common()
        {
            var item1 = new GKListItem(10, null);
            var item2 = new GKListItem(20, null);

            Assert.AreEqual(-1, item1.CompareTo(item2));

            item1 = new GKListItem(10, null);
            item2 = new GKListItem(null, null);
            Assert.AreEqual(-1, item1.CompareTo(item2));

            item1 = new GKListItem(null, null);
            item2 = new GKListItem(20, null);
            Assert.AreEqual(1, item1.CompareTo(item2));

            Assert.AreEqual(0, item1.CompareTo(item1));
            Assert.AreEqual(-1, item1.CompareTo(null));


            var subitem1 = new GKListSubItem(10);
            var subitem2 = new GKListSubItem(20);

            Assert.AreEqual(-1, subitem1.CompareTo(subitem2));

            subitem1 = new GKListSubItem(10);
            subitem2 = new GKListSubItem(null);
            Assert.AreEqual(-1, subitem1.CompareTo(subitem2));

            subitem1 = new GKListSubItem(null);
            subitem2 = new GKListSubItem(20);
            Assert.AreEqual(1, subitem1.CompareTo(subitem2));

            Assert.AreEqual(0, subitem1.CompareTo(subitem1));
            Assert.AreEqual(-1, subitem1.CompareTo(null));
        }
コード例 #2
0
ファイル: GKListView.cs プロジェクト: PQYPLZXHGF/GEDKeeper
        public int CompareTo(object obj)
        {
            GKListSubItem otherItem = obj as GKListSubItem;

            if (otherItem == null)
            {
                return(-1);
            }

            IComparable cv1 = fValue as IComparable;
            IComparable cv2 = otherItem.fValue as IComparable;

            int compRes;

            if (cv1 != null && cv2 != null)
            {
                compRes = cv1.CompareTo(cv2);
            }
            else if (cv1 != null)
            {
                compRes = -1;
            }
            else if (cv2 != null)
            {
                compRes = 1;
            }
            else
            {
                compRes = 0;
            }
            return(compRes);
        }
コード例 #3
0
ファイル: GKListView.cs プロジェクト: hazzik/GEDKeeper
        public int CompareTo(object obj)
        {
            GKListSubItem otherItem = obj as GKListSubItem;

            if (otherItem == null)
            {
                return(-1);
            }

            if (fValue is string && otherItem.fValue is string)
            {
                return(GKListView.StrCompareEx((string)fValue, (string)otherItem.fValue));
            }

            IComparable cv1 = fValue as IComparable;
            IComparable cv2 = otherItem.fValue as IComparable;

            int compRes;

            if (cv1 != null && cv2 != null)
            {
                compRes = cv1.CompareTo(cv2);
            }
            else if (cv1 != null)
            {
                compRes = -1;
            }
            else if (cv2 != null)
            {
                compRes = 1;
            }
            else
            {
                compRes = 0;
            }
            return(compRes);
        }
コード例 #4
0
ファイル: GKListView.cs プロジェクト: hazzik/GEDKeeper
        public void AddSubItem(object itemValue)
        {
            GKListSubItem subItem = new GKListSubItem(itemValue);

            SubItems.Add(subItem);
        }