public int Compare(SharpTreeNode x, SharpTreeNode y)
            {
                var a = x.Model as ITypeDefinitionModel;
                var b = y.Model as ITypeDefinitionModel;

                if (a == null && b == null)
                {
                    return(NodeTextComparer.Compare(x, y));
                }
                if (a == null)
                {
                    return(-1);
                }
                if (b == null)
                {
                    return(1);
                }

                int typeNameComparison = StringComparer.OrdinalIgnoreCase.Compare(a.Name, b.Name);

                if (typeNameComparison == 0)
                {
                    // Compare length of complete string (type parameters...)
                    if (x.Text.ToString().Length < y.Text.ToString().Length)
                    {
                        return(-1);
                    }
                    if (x.Text.ToString().Length < y.Text.ToString().Length)
                    {
                        return(1);
                    }
                }

                return(typeNameComparison);
            }
Esempio n. 2
0
            public int Compare(SharpTreeNode x, SharpTreeNode y)
            {
                // "Base types" and "Derive types" nodes have precedence over other nodes
                if ((x is BaseTypesTreeNode) && !(y is BaseTypesTreeNode))
                {
                    return(-1);
                }
                if (!(x is BaseTypesTreeNode) && (y is BaseTypesTreeNode))
                {
                    return(1);
                }
                if ((x is DerivedTypesTreeNode) && !(y is DerivedTypesTreeNode))
                {
                    return(-1);
                }
                if (!(x is DerivedTypesTreeNode) && (y is DerivedTypesTreeNode))
                {
                    return(1);
                }

                var a = x.Model as IMemberModel;
                var b = y.Model as IMemberModel;

                if ((a == null) && (b != null))
                {
                    return(-1);
                }
                if ((a != null) && (b == null))
                {
                    return(1);
                }
                if ((a != null) && (b != null))
                {
                    if (a.SymbolKind < b.SymbolKind)
                    {
                        return(-1);
                    }
                    if (a.SymbolKind > b.SymbolKind)
                    {
                        return(1);
                    }
                }

                return(NodeTextComparer.Compare(x, y));
            }