// Copyright (c) Arlo Godfrey. All Rights Reserved.
// Licensed under the GNU Lesser General Public License, Version 3.0 with additional terms.
// See the LICENSE, LICENSE.LESSER and LICENSE.ADDITIONAL files in the project root for more information.
using System;
using StrixMusic.Sdk.BaseModels;
namespace StrixMusic.Sdk.ViewModels.Helpers.Comparers
{
///
/// Compares the track number.
///
public sealed class TrackNumberComparer : InversableComparer
where TTrack : ITrackBase
{
///
/// Initializes a new instance of the class.
///
/// Sets if the comparer operates in descending order.
public TrackNumberComparer(bool isDescending = false) : base(isDescending)
{
}
///
public override int Compare(TTrack x, TTrack y)
{
// Handling nullable dataTypes while comparison using Nullable. It also compares the values of the dataType provided and returns greater,less or equal relation.
int value = Nullable.Compare(x.TrackNumber, y.TrackNumber);
return IsDescending ? -value : value;
}
}
}