Пример #1
0
        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);
        }
Пример #2
0
        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);
        }
Пример #3
0
 private void SpinTimer_Tick(object sender, EventArgs e)
 {
     Send(JsonConvert.SerializeObject(Spin.Create(spinAngle)));
     spinTimer.Enabled = true;
 }