コード例 #1
0
ファイル: ConditionTuple.cs プロジェクト: whiteschool/cmdr
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }

            ConditionTuple other = obj as ConditionTuple;

            if (other == null)
            {
                throw new ArgumentException("object must be a Tuple<ACondition, ACondition>");
            }

            // order doesn't matter

            var containsItem1 = false;

            if (Condition1 != null)
            {
                containsItem1 = Condition1.Equals(other.Condition1) || Condition1.Equals(other.Condition2);
            }
            else
            {
                containsItem1 = other.Condition1 == null || other.Condition2 == null;
            }

            var containsItem2 = false;

            if (Condition2 != null)
            {
                containsItem2 = Condition2.Equals(other.Condition2) || Condition2.Equals(other.Condition1);
            }
            else
            {
                containsItem2 = other.Condition2 == null || other.Condition1 == null;
            }

            return(containsItem1 && containsItem2);
        }
コード例 #2
0
ファイル: ConditionTuple.cs プロジェクト: whiteschool/cmdr
        /// This one is dumb and must not be called from other classes. RawMapping.Settings are ignored!
        private bool setCondition(ConditionNumber number, ACondition condition)
        {
            bool changed = false;

            if (number == ConditionNumber.One)
            {
                changed = (Condition1 != null && !Condition1.Equals(condition)) || (condition != null && !condition.Equals(Condition1));
                if (changed)
                {
                    Condition1 = condition;
                }
            }
            else
            {
                changed = (Condition2 != null && !Condition2.Equals(condition)) || (condition != null && !condition.Equals(Condition2));
                if (changed)
                {
                    Condition2 = condition;
                }
            }

            return(changed);
        }