public static string VehiclesToGuiJson(Vehicle[] v) { GuiData[] sendObj = new GuiData[v.Count()]; for (int i = 0; i < v.Count(); i++) { GuiData obj = GetGuiObj(v[i]); sendObj[i] = obj; } string str = Newtonsoft.Json.JsonConvert.SerializeObject(sendObj); return(str); }
private static GuiData GetGuiObj(Vehicle v) { lock (RouteLock) { if (v == null) { return(null); } GuiData obj = new GuiData(); obj.Num = (ushort)v.Id; //int tPtr = v.TPtr; obj.BeginX = (byte)v.BeginX; obj.BeginY = (byte)v.BeginY; obj.State = (byte)v.CurState; return(obj); } }