コード例 #1
0
        public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {
            var result = new GetAllSensorsResponse();

            while (reader.Read())
            {
                if (reader.TokenType == JsonToken.PropertyName)
                {
                    var sensorId = Convert.ToInt32(reader.Value);
                    reader.Read();
                    var sensor = serializer.Deserialize <SensorBase>(reader);
                    sensor.Id = sensorId;
                    result.Add(sensor);
                }
            }
            return(result);
        }
コード例 #2
0
 private static string ToString(GetAllSensorsResponse p)
 {
     return(string.Join(Environment.NewLine, p.Select(ToString)));
 }