bool IEquatable <UnitConversion> .Equals(UnitConversion other) { bool sourceUnitMatches = SourceUnit?.Equals(other.SourceUnit) ?? SourceUnit == other.SourceUnit; bool targetUnitMatches = TargetUnit?.Equals(other.TargetUnit) ?? TargetUnit == other.TargetUnit; return(sourceUnitMatches && targetUnitMatches); }
public bool EqualKey(UnitTranslation ItemToCompare) { bool ReturnValue; ReturnValue = TranslationFlag.Equals(ItemToCompare.TranslationFlag); if (TranslationFlag == (TranslationType)0) { ReturnValue &= (BaseUnit.Equals(ItemToCompare.BaseUnit) && TargetUnit.Equals(ItemToCompare.TargetUnit)) || (BaseUnit.Equals(ItemToCompare.TargetUnit) && TargetUnit.Equals(ItemToCompare.BaseUnit)); } if ((AffectedIngredient != null) && TranslationFlag.HasFlag(TranslationType.IsIngredientDependent)) { ReturnValue &= AffectedIngredient.Equals(ItemToCompare.AffectedIngredient); } if (TranslationFlag.HasFlag(TranslationType.IsTypeChange) && (!TranslationFlag.HasFlag(TranslationType.IsIngredientDependent))) { ReturnValue &= (IngredientType == ItemToCompare.IngredientType); } if ((TranslationFlag.HasFlag(TranslationType.IsIngredientDependent)) && (AffectedIngredient != null) && (ItemToCompare.AffectedIngredient != null)) { ReturnValue &= AffectedIngredient.Equals(ItemToCompare.AffectedIngredient); } return(ReturnValue); }