public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { JArray ja = JArray.Load(reader); double angle = ja[1].Value <double>(); Spin spin = Spin.Create(angle); return(spin); }
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) { JArray ja = new JArray(); Spin spin = (Spin)value; ja.Add(spin.type); ja.Add(spin.rotation); ja.WriteTo(writer); }
private void SpinTimer_Tick(object sender, EventArgs e) { Send(JsonConvert.SerializeObject(Spin.Create(spinAngle))); spinTimer.Enabled = true; }