Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        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);
        }