private object DeserializeInternal(int depth)
        {
            if (++depth > _depthLimit)
            {
                throw new ArgumentException(_s.GetDebugString(AtlasWeb.JSON_DepthLimitExceeded));
            }

            Nullable <Char> c = _s.GetNextNonEmptyChar();

            if (c == null)
            {
                return(null);
            }

            _s.MovePrev();

            if (IsNextElementDateTime())
            {
                return(DeserializeStringIntoDateTime());
            }

            if (IsNextElementObject(c))
            {
                IDictionary <string, object> dict = DeserializeDictionary(depth);
                // Try to coerce objects to the right type if they have the __serverType
                if (dict.ContainsKey(JavaScriptSerializer.ServerTypeFieldName))
                {
                    return(ObjectConverter.ConvertObjectToType(dict, null, _serializer));
                }
                return(dict);
            }

            if (IsNextElementArray(c))
            {
                return(DeserializeList(depth));
            }

            if (IsNextElementString(c))
            {
                return(DeserializeString());
            }

            return(DeserializePrimitiveObject());
        }
예제 #2
0
        private object DeserializeInternal(int depth)
        {
            if (++depth > this._depthLimit)
            {
                throw new ArgumentException(this._s.GetDebugString(AtlasWeb.JSON_DepthLimitExceeded));
            }
            char?nextNonEmptyChar = this._s.GetNextNonEmptyChar();
            char?nullable2        = nextNonEmptyChar;
            int? nullable4        = nullable2.HasValue ? new int?(nullable2.GetValueOrDefault()) : null;

            if (!nullable4.HasValue)
            {
                return(null);
            }
            this._s.MovePrev();
            if (this.IsNextElementDateTime())
            {
                return(this.DeserializeStringIntoDateTime());
            }
            if (IsNextElementObject(nextNonEmptyChar))
            {
                IDictionary <string, object> o = this.DeserializeDictionary(depth);
                if (o.ContainsKey("__type"))
                {
                    return(ObjectConverter.ConvertObjectToType(o, null, this._serializer));
                }
                return(o);
            }
            if (IsNextElementArray(nextNonEmptyChar))
            {
                return(this.DeserializeList(depth));
            }
            if (IsNextElementString(nextNonEmptyChar))
            {
                return(this.DeserializeString());
            }
            return(this.DeserializePrimitiveObject());
        }
예제 #3
0
 public object ConvertToType(object obj, Type targetType)
 {
     return(ObjectConverter.ConvertObjectToType(obj, targetType, this));
 }
예제 #4
0
 public T ConvertToType <T>(object obj)
 {
     return((T)ObjectConverter.ConvertObjectToType(obj, typeof(T), this));
 }