Exemple #1
0
        public override bool TryGetMember(GetMemberBinder binder, out object result)
        {
            result = _dictionary[binder.Name];

            if (result is IDictionary <string, object> )
            {
                result = new DynamicJsonObject(result as IDictionary <string, object>);
            }
            else if (result is ArrayList && (result as ArrayList) is IDictionary <string, object> )
            {
                result = new List <DynamicJsonObject>((result as ArrayList).ToArray().Select(x => new DynamicJsonObject(x as IDictionary <string, object>)));
            }
            else if (result is ArrayList)
            {
                result = new List <object>((result as ArrayList).ToArray());
            }

            return(_dictionary.ContainsKey(binder.Name));
        }
Exemple #2
0
        public object this[string key]
        {
            get
            {
                object result = _dictionary[key];

                if (result is IDictionary <string, object> )
                {
                    result = new DynamicJsonObject(result as IDictionary <string, object>);
                }
                else if (result is ArrayList && (result as ArrayList) is IDictionary <string, object> )
                {
                    result = new List <DynamicJsonObject>((result as ArrayList).ToArray().Select(x => new DynamicJsonObject(x as IDictionary <string, object>)));
                }
                else if (result is ArrayList)
                {
                    result = new List <object>((result as ArrayList).ToArray());
                }

                return(result);
            }
        }