public bool TryMakeTurbofan(float bypassratio, int numberofshafts, Generator gen, List<Spool> spools, int egt, int isp, int numberofcycles, List<Propellant> fueList, List<Oxidiser> oxidisers, string manuf, string model, string serialnumber, float maxpower, float operatingtime, float fuelflow, OnOff stat, out Turbofan incomingTurbofan, bool isgeared = false, bool hasreverse = true, PoweredAircraft parentvehicle = null) { try { Turbofan turbofan = MakeTurbofan(bypassratio, numberofshafts, gen, spools, egt, isp, numberofcycles, fueList, oxidisers, manuf, model, serialnumber, maxpower, operatingtime, fuelflow, stat, isgeared, hasreverse, parentvehicle); incomingTurbofan = turbofan; return true; } catch (ArgumentNullException argumentNullException) { Console.WriteLine(argumentNullException.Message); incomingTurbofan = null; return false; } catch (ArgumentException argumentException) { Console.WriteLine(argumentException.Message); incomingTurbofan = null; return false; } catch (Exception e) { Console.WriteLine(e.Message); incomingTurbofan = null; return false; } }
public Turbofan TryMakeTurbofan(float bypassratio, int numberofshafts, Generator gen, List<Spool> spools, int egt, int isp, int numberofcycles, List<Propellant> fueList, List<Oxidiser> oxidisers, string manuf, string model, string serialnumber, float maxpower, float operatingtime, float fuelflow, OnOff stat, bool isgeared = false, bool hasreverse = true, PoweredAircraft parentvehicle = null) { Turbofan turbofan = new Turbofan(); try { turbofan = MakeTurbofan(bypassratio, numberofshafts, gen, spools, egt, isp, numberofcycles, fueList, oxidisers, manuf, model, serialnumber, maxpower, operatingtime, fuelflow, stat, isgeared, hasreverse, parentvehicle); } catch (ArgumentNullException argumentNullException) { Console.WriteLine(argumentNullException.Message); switch (argumentNullException.ParamName) { case nameof(spools): spools = new List<Spool>(); TryMakeTurbofan(bypassratio, numberofshafts, gen, spools, egt, isp, numberofcycles, fueList, oxidisers, manuf, model, serialnumber, maxpower, operatingtime, fuelflow, stat, isgeared, hasreverse, parentvehicle); break; case nameof(serialnumber): serialnumber = "no serial number specified"; TryMakeTurbofan(bypassratio, numberofshafts, gen, spools, egt, isp, numberofcycles, fueList, oxidisers, manuf, model, serialnumber, maxpower, operatingtime, fuelflow, stat, isgeared, hasreverse, parentvehicle); break; case nameof(fueList): fueList = new List<Propellant>(); TryMakeTurbofan(bypassratio, numberofshafts, gen, spools, egt, isp, numberofcycles, fueList, oxidisers, manuf, model, serialnumber, maxpower, operatingtime, fuelflow, stat, isgeared, hasreverse, parentvehicle); break; case nameof(oxidisers): oxidisers = new List<Oxidiser>(); TryMakeTurbofan(bypassratio, numberofshafts, gen, spools, egt, isp, numberofcycles, fueList, oxidisers, manuf, model, serialnumber, maxpower, operatingtime, fuelflow, stat, isgeared, hasreverse, parentvehicle); break; } } catch (ArgumentException argumentException) when (argumentException.ParamName == nameof(numberofshafts)) { Console.WriteLine(argumentException.Message); if (argumentException.ParamName == nameof(numberofshafts)) { numberofshafts = 1; TryMakeTurbofan(bypassratio, numberofshafts, gen, spools, egt, isp, numberofcycles, fueList, oxidisers, manuf, model, serialnumber, maxpower, operatingtime, fuelflow, stat, isgeared, hasreverse, parentvehicle); } } catch (Exception e) { Console.WriteLine(e.Message); } return turbofan; }