Exemple #1
0
        public void TestComparer()
        {
            var usage1 = new ElementUsage {
                Name = "type1"
            };
            var usage2 = new ElementUsage {
                Name = "type5"
            };

            var comparer = new ElementUsageComparer();

            Assert.AreEqual(-4, comparer.Compare(usage1, usage2));
        }
Exemple #2
0
        /// <summary>
        /// Compares two <see cref="IRowViewModelBase{Thing}"/> of the same type
        /// </summary>
        /// <param name="x">The First <see cref="IRowViewModelBase{Thing}"/></param>
        /// <param name="y">The second <see cref="IRowViewModelBase{Thing}"/></param>
        /// <param name="type">The actual Type</param>
        /// <returns>
        /// Less than zero : x is "lower" than y
        /// Zero: x "equals" y.
        /// Greater than zero: x is "greater" than y.
        /// </returns>
        private int CompareSameType(IRowViewModelBase <Thing> x, IRowViewModelBase <Thing> y, Type type)
        {
            if (typeof(ParameterOrOverrideBaseRowViewModel).IsAssignableFrom(type))
            {
                var comparer = new ParameterBaseComparer();
                return(comparer.Compare((ParameterBase)x.Thing, (ParameterBase)y.Thing));
            }

            if (type == typeof(ParameterGroupRowViewModel))
            {
                var comparer = new ParameterGroupComparer();
                return(comparer.Compare((ParameterGroup)x.Thing, (ParameterGroup)y.Thing));
            }

            var usageComparer = new ElementUsageComparer();

            return(usageComparer.Compare((ElementUsage)x.Thing, (ElementUsage)y.Thing));
        }