public StationClass(JObject jo, SystemInfoSource source) { if (source == SystemInfoSource.EDDB) { name = jo["name"].Value<string>(); SearchName = name.ToLower(); eddb_id = jo["id"].Value<int>(); system_id = jo["system_id"].Value<int>(); if (jo["max_landing_pad_size"].Type == JTokenType.String) max_landing_pad_size = jo["max_landing_pad_size"].Value<string>(); if (jo["distance_to_star"].Type == JTokenType.Integer) distance_to_star = jo["distance_to_star"].Value<int>(); faction = jo["faction"].Value<string>(); government = EliteDangerous.Government2ID(jo["government"]); allegiance = EliteDangerous.Allegiance2ID(jo["allegiance"]); state = EliteDangerous.EDState2ID(jo["state"]); stationtype = EliteDangerous.EDStationType2ID(jo["type"]); if (jo["has_blackmarket"].Type == JTokenType.Integer) has_blackmarket = jo["has_blackmarket"].Value<int>(); else has_blackmarket = -1; if (jo["has_commodities"].Type == JTokenType.Integer) has_commodities = jo["has_commodities"].Value<int>(); else has_commodities = -1; if (jo["has_refuel"].Type == JTokenType.Integer) has_refuel = jo["has_refuel"].Value<int>(); else has_refuel = -1; if (jo["has_repair"].Type == JTokenType.Integer) has_repair = jo["has_repair"].Value<int>(); else has_repair = -1; if (jo["has_rearm"].Type == JTokenType.Integer) has_rearm = jo["has_rearm"].Value<int>(); else has_rearm = -1; if (jo["has_outfitting"].Type == JTokenType.Integer) has_outfitting = jo["has_outfitting"].Value<int>(); else has_outfitting = -1; if (jo["has_shipyard"].Type == JTokenType.Integer) has_shipyard = jo["has_shipyard"].Value<int>(); else has_shipyard = -1; economies = EliteDangerous.EDEconomies2ID((JArray)jo["economies"]); import_commodities = EliteDangerous.EDCommodities2ID((JArray)jo["import_commodities"]); export_commodities = EliteDangerous.EDCommodities2ID((JArray)jo["export_commodities"]); prohibited_commodities = EliteDangerous.EDCommodities2ID((JArray)jo["prohibited_commodities"]); eddb_updated_at = jo["updated_at"].Value<int>(); } }
public StationClass(JObject jo, SystemInfoSource source) { if (source == SystemInfoSource.EDDB) { name = jo["name"].Value <string>(); SearchName = name.ToLower(); eddb_id = jo["id"].Value <int>(); system_id = jo["system_id"].Value <int>(); if (jo["max_landing_pad_size"].Type == JTokenType.String) { max_landing_pad_size = jo["max_landing_pad_size"].Value <string>(); } if (jo["distance_to_star"].Type == JTokenType.Integer) { distance_to_star = jo["distance_to_star"].Value <int>(); } faction = jo["faction"].Value <string>(); government = EliteDangerous.Government2ID(jo["government"]); allegiance = EliteDangerous.Allegiance2ID(jo["allegiance"]); state = EliteDangerous.EDState2ID(jo["state"]); stationtype = EliteDangerous.EDStationType2ID(jo["type"]); if (jo["has_blackmarket"].Type == JTokenType.Integer) { has_blackmarket = jo["has_blackmarket"].Value <int>(); } else { has_blackmarket = -1; } if (jo["has_commodities"].Type == JTokenType.Integer) { has_commodities = jo["has_commodities"].Value <int>(); } else { has_commodities = -1; } if (jo["has_refuel"].Type == JTokenType.Integer) { has_refuel = jo["has_refuel"].Value <int>(); } else { has_refuel = -1; } if (jo["has_repair"].Type == JTokenType.Integer) { has_repair = jo["has_repair"].Value <int>(); } else { has_repair = -1; } if (jo["has_rearm"].Type == JTokenType.Integer) { has_rearm = jo["has_rearm"].Value <int>(); } else { has_rearm = -1; } if (jo["has_outfitting"].Type == JTokenType.Integer) { has_outfitting = jo["has_outfitting"].Value <int>(); } else { has_outfitting = -1; } if (jo["has_shipyard"].Type == JTokenType.Integer) { has_shipyard = jo["has_shipyard"].Value <int>(); } else { has_shipyard = -1; } economies = EliteDangerous.EDEconomies2ID((JArray)jo["economies"]); import_commodities = EliteDangerous.EDCommodities2ID((JArray)jo["import_commodities"]); export_commodities = EliteDangerous.EDCommodities2ID((JArray)jo["export_commodities"]); prohibited_commodities = EliteDangerous.EDCommodities2ID((JArray)jo["prohibited_commodities"]); eddb_updated_at = jo["updated_at"].Value <int>(); } }
public SystemClass(JObject jo, SystemInfoSource source) { try { if (source == SystemInfoSource.EDSM) { JObject coords = (JObject)jo["coords"]; name = jo["name"].Value<string>(); SearchName = name.ToLower(); //cr = jo["cr"].Value<int>(); x = double.NaN; y = double.NaN; z = double.NaN; if (coords != null && (coords["x"].Type == JTokenType.Float || coords["x"].Type == JTokenType.Integer)) { x = coords["x"].Value<double>(); y = coords["y"].Value<double>(); z = coords["z"].Value<double>(); } JArray submitted = (JArray)jo["submitted"]; if (submitted != null && submitted.Count > 0) { if (submitted[0]["cmdrname"] != null) CommanderCreate = submitted[0]["cmdrname"].Value<string>(); CreateDate = submitted[0]["date"].Value<DateTime>(); if (submitted[submitted.Count - 1]["cmdrname"] != null) CommanderUpdate = submitted[submitted.Count - 1]["cmdrname"].Value<string>(); UpdateDate = submitted[submitted.Count - 1]["date"].Value<DateTime>(); } UpdateDate = jo["date"].Value<DateTime>(); if (CreateDate.Year <= 1) CreateDate = UpdateDate; id_edsm = (long)jo["id"]; // pick up its edsm ID status = SystemStatusEnum.EDSC; } else if (source == SystemInfoSource.EDDB) { name = jo["name"].Value<string>(); SearchName = name.ToLower(); cr = 1; x = jo["x"].Value<double>(); y = jo["y"].Value<double>(); z = jo["z"].Value<double>(); id_eddb = jo["id"].Value<int>(); faction = jo["faction"].Value<string>(); if (jo["population"].Type == JTokenType.Integer) population = jo["population"].Value<long>(); government = EliteDangerousClass.Government2ID(jo["government"]); allegiance = EliteDangerousClass.Allegiance2ID(jo["allegiance"]); state = EliteDangerousClass.EDState2ID(jo["state"]); security = EliteDangerousClass.EDSecurity2ID(jo["security"]); primary_economy = EliteDangerousClass.EDEconomy2ID(jo["primary_economy"]); if (jo["needs_permit"].Type == JTokenType.Integer) needs_permit = jo["needs_permit"].Value<int>(); eddb_updated_at = jo["updated_at"].Value<int>(); id_edsm = (long)jo["edsm_id"]; // pick up its edsm ID status = SystemStatusEnum.EDDB; } } catch (Exception ex) { System.Diagnostics.Trace.WriteLine("SystemClass exception: " + ex.Message); } // since we don't have control of outside formats, we fail quietly. }
public SystemClass(JObject jo, SystemInfoSource source) { if (source == SystemInfoSource.RW) { try { x = jo["x"].Value<double>(); y = jo["y"].Value<double>(); z = jo["z"].Value<double>(); name = jo["name"].Value<string>(); SearchName = name.ToLower(); cr = 1; status = SystemStatusEnum.RedWizzard; } catch { } } else if (source == SystemInfoSource.EDSC) { JArray ja = (JArray)jo["coord"]; name = jo["name"].Value<string>(); SearchName = name.ToLower(); cr = jo["cr"].Value<int>(); if (ja[0].Type == JTokenType.Float || ja[0].Type == JTokenType.Integer) { x = ja[0].Value<double>(); y = ja[1].Value<double>(); z = ja[2].Value<double>(); } else { x = double.NaN; y = double.NaN; z = double.NaN; } CommanderCreate = jo["commandercreate"].Value<string>(); CreateDate = jo["createdate"].Value<DateTime>(); CommanderUpdate = jo["commanderupdate"].Value<string>(); UpdateDate = jo["updatedate"].Value<DateTime>(); status = SystemStatusEnum.EDSC; } else if (source == SystemInfoSource.EDSM) { JObject coords = (JObject)jo["coords"]; name = jo["name"].Value<string>(); SearchName = name.ToLower(); //cr = jo["cr"].Value<int>(); x = double.NaN; y = double.NaN; z = double.NaN; if (coords !=null && (coords["x"].Type == JTokenType.Float || coords["x"].Type == JTokenType.Integer)) { x = coords["x"].Value<double>(); y = coords["y"].Value<double>(); z = coords["z"].Value<double>(); } JArray submitted = (JArray)jo["submitted"]; if (submitted.Count>0) { if (submitted[0]["cmdrname"]!=null) CommanderCreate = submitted[0]["cmdrname"].Value<string>(); CreateDate = submitted[0]["date"].Value<DateTime>(); if (submitted[submitted.Count - 1]["cmdrname"] != null) CommanderUpdate = submitted[submitted.Count-1]["cmdrname"].Value<string>(); UpdateDate = submitted[submitted.Count-1]["date"].Value<DateTime>(); } status = SystemStatusEnum.EDSC; } else if (source == SystemInfoSource.EDDB) { name = jo["name"].Value<string>(); SearchName = name.ToLower(); cr = 1; x = jo["x"].Value<double>(); y = jo["y"].Value<double>(); z = jo["z"].Value<double>(); id_eddb = jo["id"].Value<int>(); /*CommanderCreate = jo["commandercreate"].Value<string>(); CreateDate = jo["createdate"].Value<DateTime>(); CommanderUpdate = jo["commanderupdate"].Value<string>(); UpdateDate = jo["updatedate"].Value<DateTime>();*/ faction = jo["faction"].Value<string>(); if (jo["population"].Type == JTokenType.Integer) population = jo["population"].Value<long>(); government = EliteDangerous.Government2ID(jo["government"]); allegiance = EliteDangerous.Allegiance2ID(jo["allegiance"]); state = EliteDangerous.EDState2ID(jo["state"]); security = EliteDangerous.EDSecurity2ID(jo["security"]); primary_economy = EliteDangerous.EDEconomy2ID(jo["primary_economy"]); if (jo["needs_permit"].Type == JTokenType.Integer) needs_permit = jo["needs_permit"].Value<int>(); eddb_updated_at = jo["updated_at"].Value<int>(); status = SystemStatusEnum.EDDB; } }
public SystemClass(JObject jo, SystemInfoSource source) { if (source == SystemInfoSource.RW) { try { x = jo["x"].Value <double>(); y = jo["y"].Value <double>(); z = jo["z"].Value <double>(); name = jo["name"].Value <string>(); SearchName = name.ToLower(); cr = 1; status = SystemStatusEnum.RedWizzard; } catch { } } else if (source == SystemInfoSource.EDSC) { JArray ja = (JArray)jo["coord"]; name = jo["name"].Value <string>(); SearchName = name.ToLower(); cr = jo["cr"].Value <int>(); if (ja[0].Type == JTokenType.Float || ja[0].Type == JTokenType.Integer) { x = ja[0].Value <double>(); y = ja[1].Value <double>(); z = ja[2].Value <double>(); } else { x = double.NaN; y = double.NaN; z = double.NaN; } CommanderCreate = jo["commandercreate"].Value <string>(); CreateDate = jo["createdate"].Value <DateTime>(); CommanderUpdate = jo["commanderupdate"].Value <string>(); UpdateDate = jo["updatedate"].Value <DateTime>(); status = SystemStatusEnum.EDSC; } else if (source == SystemInfoSource.EDSM) { JObject coords = (JObject)jo["coords"]; name = jo["name"].Value <string>(); SearchName = name.ToLower(); //cr = jo["cr"].Value<int>(); x = double.NaN; y = double.NaN; z = double.NaN; if (coords != null && (coords["x"].Type == JTokenType.Float || coords["x"].Type == JTokenType.Integer)) { x = coords["x"].Value <double>(); y = coords["y"].Value <double>(); z = coords["z"].Value <double>(); } JArray submitted = (JArray)jo["submitted"]; if (submitted != null && submitted.Count > 0) { if (submitted[0]["cmdrname"] != null) { CommanderCreate = submitted[0]["cmdrname"].Value <string>(); } CreateDate = submitted[0]["date"].Value <DateTime>(); if (submitted[submitted.Count - 1]["cmdrname"] != null) { CommanderUpdate = submitted[submitted.Count - 1]["cmdrname"].Value <string>(); } UpdateDate = submitted[submitted.Count - 1]["date"].Value <DateTime>(); } UpdateDate = jo["date"].Value <DateTime>(); if (CreateDate.Year <= 1) { CreateDate = UpdateDate; } status = SystemStatusEnum.EDSC; } else if (source == SystemInfoSource.EDDB) { name = jo["name"].Value <string>(); SearchName = name.ToLower(); cr = 1; x = jo["x"].Value <double>(); y = jo["y"].Value <double>(); z = jo["z"].Value <double>(); id_eddb = jo["id"].Value <int>(); /*CommanderCreate = jo["commandercreate"].Value<string>(); * CreateDate = jo["createdate"].Value<DateTime>(); * CommanderUpdate = jo["commanderupdate"].Value<string>(); * UpdateDate = jo["updatedate"].Value<DateTime>();*/ faction = jo["faction"].Value <string>(); if (jo["population"].Type == JTokenType.Integer) { population = jo["population"].Value <long>(); } government = EliteDangerous.Government2ID(jo["government"]); allegiance = EliteDangerous.Allegiance2ID(jo["allegiance"]); state = EliteDangerous.EDState2ID(jo["state"]); security = EliteDangerous.EDSecurity2ID(jo["security"]); primary_economy = EliteDangerous.EDEconomy2ID(jo["primary_economy"]); if (jo["needs_permit"].Type == JTokenType.Integer) { needs_permit = jo["needs_permit"].Value <int>(); } eddb_updated_at = jo["updated_at"].Value <int>(); status = SystemStatusEnum.EDDB; } }