/* Copyright 2007-2013 The NGenerics Team (https://github.com/ngenerics/ngenerics/wiki/Team) This program is licensed under the GNU Lesser General Public License (LGPL). You should have received a copy of the license along with the source code. If not, an online copy of the license can be found at http://www.gnu.org/copyleft/lesser.html. */ using System; using System.Collections.Generic; using NGenerics.Util; namespace NGenerics.Comparers { /// /// A Comparer using a Comparison delegate for comparisons between items. /// /// The type of the objects to compare. //[Serializable] public sealed class ComparisonComparer : IComparer { #region Globals private Comparison comparison; #endregion #region Construction /// The comparison. /// is a null reference (Nothing in Visual Basic). public ComparisonComparer(Comparison comparison) { Guard.ArgumentNotNull(comparison, "comparison"); this.comparison = comparison; } #endregion #region Public Members /// /// Gets or sets the comparison used in this comparer. /// /// The comparison used in this comparer. /// is a null reference (Nothing in Visual Basic). public Comparison Comparison { get { return comparison; } set { Guard.ArgumentNotNull(value, "value"); comparison = value; } } #endregion #region IComparer Members /// public int Compare(T x, T y) { return comparison(x, y); } #endregion } }