public void Execute() { StarsList.Add( new SpectralClass { SpectralClassName = "O", MassOfTheSun = 32, Count = 55000, Part = 0.00002 }); StarsList.Add( new SpectralClass { SpectralClassName = "F", MassOfTheSun = 1.25, Count = 12000000000, Part = 2.9 }); StarsList.Add( new SpectralClass { SpectralClassName = "D", MassOfTheSun = 1.7, Count = 12000000, Part = 1.2 }); Status = LoadStatus.Success; }
public void Execute() { Status = LoadStatus.None; if (FileName == "") { Status = LoadStatus.FileNameIsEmpty; throw new Exception("File name is empty"); } if (!File.Exists(FileName)) { Status = LoadStatus.FileNotExists; throw new Exception("File not found"); } using (StreamReader reader = new StreamReader(FileName)) { while (!reader.EndOfStream) { string line = reader.ReadLine(); try { string[] arr = line.Split('|'); if (StarsList == null) { StarsList = new List <SpectralClass>(); } StarsList.Add( new SpectralClass { SpectralClassName = arr[0], MassOfTheSun = double.Parse(arr[1]), Part = double.Parse(arr[2]), Count = long.Parse(arr[3]) }); OnLoadFile?.Invoke(StarsList.Count); } catch (Exception ex) { LogUtility.ErrorLog(ex); Status = LoadStatus.GeneralError; } } } Status = LoadStatus.Success; }