示例#1
0
        public override bool Equals(object rval)
        {
            if (!(rval is DocumentValue))
            {
                return(false);
            }
            DocumentValue doc = (DocumentValue)rval;

            if (values.Count != doc.values.Count)
            {
                return(false);
            }
            foreach (string key in values.Keys)
            {
                if (!doc.values.ContainsKey(key))
                {
                    return(false);
                }
                Object lival = values[key];
                Object rival = doc.values[key];
                if (!lival.Equals(rival))
                {
                    return(false);
                }
            }
            return(true);
        }
示例#2
0
        public override IValue ToDocumentValue(Context context)
        {
            DocumentValue doc = new DocumentValue();

            foreach (String key in values.Keys)
            {
                IValue value = null;
                if (!values.TryGetValue(key, out value))
                {
                    value = NullValue.Instance;
                }

                doc.SetMemberValue(context, key, value.ToDocumentValue(context));
            }
            return(doc);
        }
示例#3
0
        public IValue GetMember(String name, bool autoCreate)
        {
            IValue result = null;

            if (values.TryGetValue(name, out result))
            {
                return(result);
            }
            else if ("text" == name)
            {
                return(new TextValue(this.ToString()));
            }
            else if (autoCreate)
            {
                result       = new DocumentValue();
                values[name] = result;
                return(result);
            }
            else
            {
                return(NullValue.Instance);
            }
        }