public void delete(object obj, int id) { ecommand c = ecommand.ce; if (obj as caddressBook != null) { c = ecommand.daddressBook; } else if (obj as ccontacts != null) { c = ecommand.dcontacts; } else if (obj as cdiary != null) { c = ecommand.ddiary; } else if (obj as cmemorandum != null) { c = ecommand.dmemorandum; } else if (obj as cproperty != null) { c = ecommand.dproperty; } string json = JsonConvert.SerializeObject(id); ctransmitter transmitter = new ctransmitter(this.id, c, json); send(transmitter.ToString()); }
public void add <T>(T obj) { string temp = typeof(T).ToString(); //int i = temp.LastIndexOf('.'); //temp = temp.Substring(i + 1); ecommand c = ecommand.ce; if (string.Equals(temp, typeof(caddressBook).ToString())) { c = ecommand.addaddressBook; } else if (string.Equals(temp, typeof(ccontacts).ToString())) { c = ecommand.addcontacts; } else if (string.Equals(temp, typeof(cdiary).ToString())) { c = ecommand.adddiary; } else if (string.Equals(temp, typeof(cmemorandum).ToString())) { c = ecommand.addmemorandum; } else if (string.Equals(temp, typeof(cproperty).ToString())) { c = ecommand.addproperty; } string json = JsonConvert.SerializeObject(obj); ctransmitter transmitter = new ctransmitter(id, c, json); send(transmitter.ToString()); }
private void implement(string str) { try { ctransmitter transmitter = JsonConvert.DeserializeObject <ctransmitter>(str); ecommand command = (ecommand)Enum.Parse(typeof(ecommand), transmitter.command); int id = Convert.ToInt32(transmitter.id); switchimplement(id, command, transmitter.str); } catch (Exception e) { reminder("slaveComputer.implement:str不是ctransmitter " + e.Message); reminder(str); } }
private void implement(string str) { try { ctransmitter transmitter = JsonConvert.DeserializeObject <ctransmitter>(str); ecommand command = (ecommand)Enum.Parse(typeof(ecommand), transmitter.command); switch (command) { case ecommand.ce: reminder("收到" + transmitter.id); break; } } catch (Exception e) { reminder("str不是ctransmitter " + e.Message); } }
public void send(ecommand command, string str) { ctransmitter transmitter = new ctransmitter(id, command, str); send(transmitter.ToString()); }
public void getdata() { ctransmitter transmitter = new ctransmitter(id, ecommand.getdata, string.Empty); send(transmitter.ToString()); }