Esempio n. 1
0
        public object Deserialize(string contentType, Stream bodyStream, BindingContext context)
        {
            var deserializedObject = JsonSerializer.DeserializeFromStream(context.DestinationType, bodyStream);

            if (context.DestinationType.GetProperties(BindingFlags.Public | BindingFlags.Instance).Except(context.ValidModelProperties).Any())
            {
                return(CreateObjectWithBlacklistExcluded(context, deserializedObject));
            }

            return(deserializedObject);
        }
Esempio n. 2
0
 public void Serialize <TModel>(string contentType, TModel model, Stream outputStream)
 {
     JsonSerializer.SerializeToStream(model, outputStream);
 }
Esempio n. 3
0
        public override Task WriteToStreamAsync(Type type, object value, Stream writeStream, System.Net.Http.HttpContent content, TransportContext transportContext)
        {
            var task = Task.Factory.StartNew(() => JsonSerializer.SerializeToStream(value, type, writeStream));

            return(task);
        }
Esempio n. 4
0
        public override Task <object> ReadFromStreamAsync(Type type, Stream readStream, System.Net.Http.HttpContent content, IFormatterLogger formatterLogger)
        {
            var task = Task <object> .Factory.StartNew(() => JsonSerializer.DeserializeFromStream(type, readStream));

            return(task);
        }
Esempio n. 5
0
 public string Json_DifferenetSerialize()
 {
     return(JsonSerializer.SerializeToString(jsonRoot));
 }
Esempio n. 6
0
        /// <summary>
        /// Get JSON string value converted to T
        /// </summary>
        public static T Get <T>(this Dictionary <string, string> map, string key, T defaultValue = default(T))
        {
            string strVal;

            return(map.TryGetValue(key, out strVal) ? JsonSerializer.DeserializeFromString <T>(strVal) : defaultValue);
        }