예제 #1
0
        public int CompareTo(Reference other)
        {
            int compare = Book.CompareTo(other.Book);

            if (compare == 0)
            {
                compare = Chapter.CompareTo(other.Chapter);
            }

            if (compare == 0)
            {
                Verses       = Verses.OrderBy(v => v).ToArray();
                other.Verses = other.Verses.OrderBy(v => v).ToArray();

                for (int i = 0; compare == 0 && i < Math.Max(Verses.Length, other.Verses.Length); i++)
                {
                    if (i < Verses.Length && i < other.Verses.Length)
                    {
                        compare = Verses[i].CompareTo(other.Verses[i]);
                    }
                    else
                    {
                        compare = Verses.Length - other.Verses.Length;
                    }
                }
            }

            return(compare);
        }
        public int CompareTo(RulesTable other)
        {
            string[] thisParts  = Name.Split(':');
            string[] otherParts = Name.Split(':');
            int      compVal;

            if (Chapter != 0 && other.Chapter != 0)
            {
                compVal = Chapter.CompareTo(other.Chapter);
                switch (compVal)
                {
                case 0:
                    return(Number.CompareTo(other.Number));

                default:
                    return(compVal);
                }
            }
            else
            {
                if (Chapter == 0 && other.Chapter == 0)
                {
                    return(thisParts[1].CompareTo(otherParts[1]));
                }
                else if (Chapter == 0)
                {
                    return(-1);
                }
                else
                {
                    return(+1);
                }
            }
        }