private bool VerifyData(PortsAndASurveyorsData data) { if (data.Ports == null || data.Surveyors == null) { return(false); } if (data.Ports.SelectMany(x => x.Surveyors).Any(x => !data.Surveyors.ContainsKey(x))) { return(false); } if (data.Ports.Any(x => x.Surveyors.Count == 0)) { return(false); } return(true); }
void LoadPortsAndSurveyorsData(string json) { try { data = PortsAndASurveyorsData.FromJson(json); } catch (JsonSerializationException) { data = null; statusLabel.Text = "Invalid Data Detected"; Controls.Cast <Control>().ForEach(x => x.Enabled = false); return; } if (!VerifyData(data)) { data = null; statusLabel.Text = "Invalid Data Detected"; Controls.Cast <Control>().ForEach(x => x.Enabled = false); return; } statusLabel.Text = "Successfully loaded ports and surveyors data."; }
public static string ToJson(this PortsAndASurveyorsData self) => JsonConvert.SerializeObject(self, Converter.Settings);