示例#1
0
 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);
 }
示例#2
0
 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.";
 }
示例#3
0
 public static string ToJson(this PortsAndASurveyorsData self) => JsonConvert.SerializeObject(self, Converter.Settings);