Пример #1
0
        static public int CategorySort(Type p_type1, Type p_type2)
        {
            CategoryAttribute attribute1      = p_type1.GetCustomAttribute <CategoryAttribute>();
            CategoryAttribute attribute2      = p_type2.GetCustomAttribute <CategoryAttribute>();
            string            categoryString1 = attribute1 == null ? "Other" : NodeUtils.CategoryToString(attribute1.type);
            string            categoryString2 = attribute2 == null ? "Other" : NodeUtils.CategoryToString(attribute2.type);
            string            nodeString1     = p_type1.ToString().Substring(p_type1.ToString().IndexOf(".") + 1);
            string            nodeString2     = p_type2.ToString().Substring(p_type2.ToString().IndexOf(".") + 1);

            if (categoryString1 == categoryString2)
            {
                return(nodeString1.CompareTo(nodeString2));
            }

            if (categoryString1 == "Graph")
            {
                return(1);
            }

            if (categoryString2 == "Graph")
            {
                return(-1);
            }

            return(categoryString1.CompareTo(categoryString2));
        }