Ejemplo n.º 1
0
 internal static object Deserialize(JavaScriptSerializer serializer, string input, Type type, int depthLimit)
 {
     if (input == null)
     {
         throw new ArgumentNullException("input");
     }
     if (input.Length > serializer.MaxJsonLength)
     {
         throw new ArgumentException(JSON_MaxJsonLengthExceeded, "input");
     }
     return(ObjectConverter.ConvertObjectToType(JavaScriptObjectDeserializer.BasicDeserialize(input, depthLimit, serializer), type, serializer));
 }
Ejemplo n.º 2
0
        private object DeserializeInternal(int depth)
        {
            if (++depth > this._depthLimit)
            {
                throw new ArgumentException(this._s.GetDebugString(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());
        }
Ejemplo n.º 3
0
 public T ConvertToType <T>(object obj)
 {
     return((T)ObjectConverter.ConvertObjectToType(obj, typeof(T), this));
 }