Example #1
0
        public override bool Equals(object rval)
        {
            if (!(rval is DictValue))
            {
                return(false);
            }
            DictValue dict = (DictValue)rval;

            if (this.Count != dict.Count)
            {
                return(false);
            }
            foreach (TextValue key in this.Keys)
            {
                if (!dict.ContainsKey(key))
                {
                    return(false);
                }
                Object lival = this[key];
                Object rival = dict[key];
                if (!lival.Equals(rival))
                {
                    return(false);
                }
            }
            return(true);
        }
Example #2
0
        public bool Equals(Context context, IValue rval)
        {
            if (!(rval is DictValue))
            {
                return(false);
            }
            DictValue dict = (DictValue)rval;

            if (this.Count != dict.Count)
            {
                return(false);
            }
            foreach (TextValue key in this.Keys)
            {
                if (!dict.ContainsKey(key))
                {
                    return(false);
                }
                Object lival = this[key];
                if (lival is IExpression)
                {
                    lival = ((IExpression)lival).interpret(context);
                }
                Object rival = dict[key];
                if (rival is IExpression)
                {
                    rival = ((IExpression)rival).interpret(context);
                }
                if (lival is IValue && rival is IValue)
                {
                    if (!((IValue)lival).Equals(context, (IValue)rival))
                    {
                        return(false);
                    }
                }
                else if (!lival.Equals(rival))
                {
                    return(false);
                }
            }
            return(true);
        }