Exemplo n.º 1
0
        public static InspectionInfo CreateDefault(int axleCount, DateTime time)
        {
            int            vehicleCount = (int)Math.Ceiling(axleCount / 4.0);
            InspectionInfo info         = new InspectionInfo();

            info.Time = time.ToString("yyyyMMddHHmmss");
            info.Type = "TrainRecord";
            for (int i = 0; i < vehicleCount; i++)
            {
                info.Vehicles.Add(new InspectionVehicle());
            }
            for (int i = 0; i < axleCount * 2; i++)
            {
                info.Wheels.Add(new InspectionWheel());
            }
            for (int i = 0; i < 0; i++)
            {
                //set info.Defects null
            }
            for (int i = 0; i < (int)Math.Ceiling(vehicleCount / 4.0); i++)
            {
                info.Formations.Add(new Formation());
            }
            return(info);
        }
Exemplo n.º 2
0
 public static InspectionInfo Create(FileInfo file)
 {
     if (file is null || !File.Exists(file.FullName))
     {
         throw new ArgumentNullException(nameof(file));
     }
     using (StreamReader sr = File.OpenText(file.FullName))
     {
         string         json   = sr.ReadToEnd();
         InspectionInfo result = JsonConvert.DeserializeObject <InspectionInfo>(json);
         return(result);
     }
 }