Ejemplo n.º 1
0
        public override void WriteJson(Newtonsoft.Json.JsonWriter writer, object value, Newtonsoft.Json.JsonSerializer serializer)
        {
            try
            {
                _isWriting = true;

                var jObject = Newtonsoft.Json.Linq.JObject.FromObject(value, serializer);
                jObject.AddFirst(new Newtonsoft.Json.Linq.JProperty(_discriminator, GetSubtypeDiscriminator(value.GetType())));
                writer.WriteToken(jObject.CreateReader());
            }
            finally
            {
                _isWriting = false;
            }
        }
        public void WriteToken(JsonToken jsonToken, object value)
        {
            var newtonsoftJsonToken = (Newtonsoft.Json.JsonToken)Enum.Parse(typeof(Newtonsoft.Json.JsonToken), jsonToken.ToString());

            _jsonWriter.WriteToken(newtonsoftJsonToken, value);
        }