Exemple #1
0
 public void EqualityTest()
 {
     using var i        = new ShellItem(testDoc);
     using var l        = new ShellLink(testLinkDoc);
     using ShellItem lt = l.Target;
     Assert.That(i == lt, Is.True);
     Assert.That(i != lt, Is.False);
     Assert.That(i.Equals(lt), Is.True);
     Assert.That(i.CompareTo(lt), Is.Zero);
     Assert.That(i.CompareTo(l), Is.Not.Zero);
     Assert.That(((IComparable <ShellItem>)i).CompareTo(lt), Is.Zero);
     Assert.That(((IComparable <ShellItem>)i).CompareTo(l), Is.Not.Zero);
     Assert.That(i.Equals(lt.IShellItem), Is.True);
     Assert.That(i.Equals(lt.Name), Is.False);
     Assert.That(i.Equals((object)null), Is.False);
     Assert.That(i.Equals((IShellItem)null), Is.False);
     Assert.That(i.Equals((ShellItem)null), Is.False);
     Assert.That(i.GetHashCode(), Is.EqualTo(lt.GetHashCode()));
 }
Exemple #2
0
        public int Compare(ListViewItem x, ListViewItem y)
        {
            ShellItem shX = (ShellItem)x.Tag;
            ShellItem shY = (ShellItem)y.Tag;

            if (shX != null && shY != null)
            {
                return(shY.CompareTo(shX));
            }
            else if (shX != null)
            {
                return(1);
            }
            else if (shY != null)
            {
                return(-1);
            }
            else
            {
                return(0);
            }
        }
Exemple #3
0
        public int Compare(object x, object y)
        {
            TreeNode  nodeX = x as TreeNode;
            TreeNode  nodeY = y as TreeNode;
            ShellItem shX   = (ShellItem)nodeX.Tag;
            ShellItem shY   = (ShellItem)nodeY.Tag;

            if (shX != null && shY != null)
            {
                return(shY.CompareTo(shX));
            }
            else if (shX != null)
            {
                return(1);
            }
            else if (shY != null)
            {
                return(-1);
            }
            else
            {
                return(0);
            }
        }