Exemple #1
0
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }

            ACondition other = obj as ACondition;

            if (other == null)
            {
                throw new ArgumentException();
            }

            var val      = GetValue();
            var valOther = other.GetValue();

            bool equal = Id.Equals(other.Id) && Assignment.Equals(other.Assignment);

            if (val != null)
            {
                equal &= val.Equals(valOther);
            }

            return(equal);
        }
Exemple #2
0
        /// <summary>
        /// Set condition by another condition.
        /// </summary>
        /// <param name="mappingSettings">Format.MappingSettings needed by proxy for creation of condition</param>
        /// <param name="number">Number of condition</param>
        /// <param name="condition">ACondition or null to reset condition.</param>
        /// <returns>True if condition was changed.</returns>
        internal bool SetCondition(Format.MappingSettings mappingSettings, ConditionNumber number, ACondition condition)
        {
            if (condition == null)
            {
                return(setCondition(number, condition));
            }
            else
            {
                bool changed = false;

                var targetCondition = (number == ConditionNumber.One) ? Condition1 : Condition2;

                if (targetCondition == null || targetCondition.Id != condition.Id)
                {
                    changed         = SetCondition(mappingSettings, number, Conditions.All.GetConditionProxy(condition.Id));
                    targetCondition = (number == ConditionNumber.One) ? Condition1 : Condition2; // needed?
                }

                // set assignment
                if (!changed)
                {
                    changed |= targetCondition.Assignment != condition.Assignment;
                }
                targetCondition.Assignment = condition.Assignment;

                // set value
                var newValue = condition.GetValue();
                if (!changed)
                {
                    changed |= targetCondition.GetValue() != newValue;
                }
                targetCondition.SetValue(newValue);

                return(changed);
            }
        }