public static OrderInfo ReadFromJObject(JArray o) { if ( o == null ) return null; return new OrderInfo() { Price = o.Value<decimal>(0), Amount = o.Value<decimal>(1), }; }
public static SimpleOrderInfo CreateFromJObject(JArray obj) { if (obj == null) { return null; } var r = new SimpleOrderInfo() { Price = obj.Value<decimal>(0), Amount = obj.Value<decimal>(1), }; return r; }
internal static MarketOrder ParseMarketDepth(JArray depthArray, OrderType orderType) { return new MarketOrder(orderType, depthArray.Value<decimal>(0), depthArray.Value<decimal>(1)); }
protected List<TJSONValue> buildElements(JArray arr) { try { List<TJSONValue> res = new List<TJSONValue>(); for (int i = 0; i < arr.Count; i++) { switch (arr[i].Type) { case JTokenType.Null: { res.Add(new TJSONNull()); break; } case JTokenType.String: { res.Add(new TJSONString(arr.Value<string>(i))); break; } case JTokenType.Float: { res.Add(new TJSONNumber(arr.Value<float>(i))); break; } case JTokenType.Integer: { res.Add(new TJSONNumber(arr.Value<long>(i))); break; } case JTokenType.Array: { res.Add(new TJSONArray(arr.Value<JArray>(i))); break; } case JTokenType.Object: { res.Add(new TJSONObject(arr.Value<JObject>(i))); break; } case JTokenType.Boolean: { if (arr.Value<Boolean>(i)) res.Add(new TJSONTrue()); else res.Add(new TJSONFalse()); break; } } } return res; } catch (Exception) { return null; } }
private static void ApplyMatrix(ref Matrix3D matrix, JArray values) { matrix.M11 = values.Value<double>(0); matrix.M12 = values.Value<double>(1); matrix.M13 = values.Value<double>(2); matrix.M14 = values.Value<double>(3); matrix.M21 = values.Value<double>(4); matrix.M22 = values.Value<double>(5); matrix.M23 = values.Value<double>(6); matrix.M24 = values.Value<double>(7); matrix.M31 = values.Value<double>(8); matrix.M32 = values.Value<double>(9); matrix.M33 = values.Value<double>(10); matrix.M34 = values.Value<double>(11); matrix.OffsetX = values.Value<double>(12); matrix.OffsetY = values.Value<double>(13); matrix.OffsetZ = values.Value<double>(14); matrix.M44 = values.Value<double>(15); }
public int position_source; // int Origin of this state’s position: 0 = ADS-B, 1 = ASTERIX, 2 = MLAT*/ // not sure I like this, as we are very schema sensitive, but there is no other way to get this. // ToDo: need to check the api definition for potential handling requirement of null values etc // maybe need to give some thought to what the null values should represent, // and if we want to propagate these nulls... // currently quick and dirty setting strings to empty, bool to false and numbers to 0 public static State ConvertJArray(Newtonsoft.Json.Linq.JArray array) { if (array.Count < 17) { throw new Exception("unexpected number of elements in Json Array retrieved from service"); } State result = new State(); result.icao24 = CheckJArrayValue(array[0]) ? array.Value <string>(0) : ""; result.callsign = CheckJArrayValue(array[1]) ? array.Value <string>(1) : ""; result.origin_country = CheckJArrayValue(array[2]) ? array.Value <string>(2) : ""; result.time_position = CheckJArrayValue(array[3]) ? array.Value <int>(3) : 0; result.last_contact = CheckJArrayValue(array[4]) ? array.Value <int>(4) : 0; result.longitude = CheckJArrayValue(array[5]) ? array.Value <float>(5) : 0; result.latitude = CheckJArrayValue(array[6]) ? array.Value <float>(6) : 0; result.baro_altitude = CheckJArrayValue(array[7]) ? array.Value <float>(7) : 0; result.on_ground = CheckJArrayValue(array[8]) ? array.Value <bool>(8) : false; result.velocity = CheckJArrayValue(array[9]) ? array.Value <float>(9) : 0; result.true_track = CheckJArrayValue(array[10]) ? array.Value <float>(10) : 0; result.vertical_rate = CheckJArrayValue(array[11]) ? array.Value <float>(11) : 0; result.sensors = CheckJArrayValue(array[12]) ? array.Value <int[]>(12) : new int [0]; result.geo_altitude = CheckJArrayValue(array[13]) ? array.Value <float>(13) : 0; result.squawk = CheckJArrayValue(array[14]) ? array.Value <string>(14) : ""; result.spi = CheckJArrayValue(array[15]) ? array.Value <bool>(15) : false; result.position_source = CheckJArrayValue(array[16]) ? array.Value <int>(16) : 0; return(result); }