// Constructors /// <summary> /// Initializes a new instance of this type. /// </summary> /// <param name="comparer">Comparer to provide the delegates for.</param> private AdvancedComparerStruct(AdvancedComparer <T> comparer) { Comparer = comparer; Compare = Comparer?.Compare; Equals = Comparer?.Equals; GetHashCode = Comparer?.GetHashCode; GetNearestValue = Comparer?.GetNearestValue; ValueRangeInfo = Comparer?.ValueRangeInfo; }
/// <summary> /// Deserializes the instance of this class. /// </summary> /// <param name="info">Serialization info.</param> /// <param name="context">Streaming context.</param> private AdvancedComparerStruct(SerializationInfo info, StreamingContext context) { Comparer = (AdvancedComparer <T>)info.GetValue("Comparer", typeof(AdvancedComparer <T>)); Compare = Comparer?.Compare; Equals = Comparer?.Equals; GetHashCode = Comparer?.GetHashCode; GetNearestValue = Comparer?.GetNearestValue; ValueRangeInfo = Comparer?.ValueRangeInfo; }
// Constructors /// <summary> /// Initializes new instance of this type. /// </summary> public CastingComparer(AdvancedComparer <TSource> sourceComparer) : base(sourceComparer.Provider, sourceComparer.ComparisonRules) { this.sourceComparer = sourceComparer; ValueRangeInfo <TSource> vi = sourceComparer.ValueRangeInfo; ValueRangeInfo = new ValueRangeInfo <TTarget>( vi.HasMinValue, vi.HasMinValue ? toTarget(vi.MinValue) : default(TTarget), vi.HasMaxValue, vi.HasMaxValue ? toTarget(vi.MaxValue) : default(TTarget), vi.HasDeltaValue, vi.HasDeltaValue ? toTarget(vi.DeltaValue) : default(TTarget)); }
private void Initialize() { systemComparer = new AdvancedComparer <T>(null); nullHashCode = systemComparer.GetHashCode(null); ValueRangeInfo = systemComparer.ValueRangeInfo; }