public void TestComparer() { var type1 = new EnumerationParameterType { Name = "a" }; var type2 = new EnumerationParameterType { Name = "c" }; var para1 = new Parameter { ParameterType = type1 }; var para2 = new Parameter { ParameterType = type2 }; var comparer = new ParameterBaseComparer(); Assert.AreEqual(-2, comparer.Compare(para1, para2)); type1.Name = "d"; Assert.AreEqual(1, comparer.Compare(para1, para2)); type2.Name = "d"; Assert.AreEqual(0, comparer.Compare(para1, para2)); }
/// <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)); } var groupComparer = new ParameterGroupComparer(); return(groupComparer.Compare((ParameterGroup)x.Thing, (ParameterGroup)y.Thing)); }
/// <summary> /// Compares two <see cref="IRowViewModelBase{Thing}"/> /// </summary> /// <param name="x">The first <see cref="IRowViewModelBase{Thing}"/> to compare</param> /// <param name="y">The second <see cref="IRowViewModelBase{Thing}"/> to compare</param> /// <returns> /// Less than zero : x is "lower" than y /// Zero: x "equals" y. /// Greater than zero: x is "greater" than y. /// </returns> public int Compare(IRowViewModelBase <Thing> x, IRowViewModelBase <Thing> y) { if (x == null || y == null) { throw new ArgumentNullException(); } if (!(x is PublicationParameterOrOverrideRowViewModel) || !(y is PublicationParameterOrOverrideRowViewModel)) { throw new NotSupportedException("The list contains other types of row than the specified ones."); } var comparer = new ParameterBaseComparer(); return(comparer.Compare((ParameterOrOverrideBase)x.Thing, (ParameterOrOverrideBase)y.Thing)); }
/// <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 (type == typeof(ParameterRowViewModel)) { 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)); }
/// <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) || typeof(ParameterSubscriptionRowViewModel).IsAssignableFrom(type)) { var comparer = new ParameterBaseComparer(); return(comparer.Compare((ParameterBase)x.Thing, (ParameterBase)y.Thing)); } if (typeof(ParameterGroupRowViewModel).IsAssignableFrom(type)) { 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)); }
public void TestComparer2() { var type1 = new CompoundParameterType { Name = "C" }; var type2 = new BooleanParameterType { Name = "a" }; var para1 = new Parameter { ParameterType = type1 }; var para2 = new Parameter { ParameterType = type2 }; var comparer = new ParameterBaseComparer(); Assert.AreEqual(2, comparer.Compare(para1, para2)); }