public static Owner LoadOwnerInformation(string[] lines, ref int index) { Owner owner = new Owner(); var assembly = Assembly.GetExecutingAssembly(); var userType = assembly.GetType("GarageManagementSystem.Owner"); int propertiesCount = Service.PropertiesCount(owner); // Get the number of properties for (int i = 0; i < propertiesCount; i++, index++) { var property = userType.GetProperty(lines[index]); index++; if (property.Name == "Address") { if (lines[index] != "-") { index++; Address address = Address.LoadAddressInformation(lines, ref index); property.SetValue(owner, address, null); } } else { if (lines[index] != "-") { var currentPropertyType = property.PropertyType; var convertedValue = Convert.ChangeType(lines[index], currentPropertyType, null); property.SetValue(owner, convertedValue, null); } } } index--; return owner; }
private static void LoadHardCodeInformation() { // Owners Address owner1Address = new Address("Sofia", "2000", "Geo Milev", "ul. Ivan Vazov", 2, "no comment"); Owner owner1 = new Owner("Ivan Peshev", owner1Address, "0883442233", "*****@*****.**", "no comment"); Address owner2Address = new Address("Plovdiv", "1800", "j.k. Zapad", "ul. Opulchenska", 132, "no comment"); Owner owner2 = new Owner("Georgi Georgiev", owner2Address, "0883412333", "*****@*****.**", "no comment"); // Parts List<Part> parts = new List<Part>(){ new Part(1234, "Wheel", 50.00m, new List<VehicleInformation>(){ new VehicleInformation("Peugeot", "106", 1999, FuelType.Diesel, Gearbox.Automatic), new VehicleInformation("BMW", "5", 2002, FuelType.Electric, Gearbox.SemiAutomatic), new VehicleInformation("Mercedes", "SLK", 2010, FuelType.Electric, Gearbox.SemiAutomatic) } ) }; // Repairs List<Repair> repairsCar1 = new List<Repair>(); repairsCar1.Add(new Repair("Change wheels", 48, parts)); List<Repair> repairsCar2 = new List<Repair>(); repairsCar2.Add(new Repair("Change front wheels", 48, parts)); // Vehicles Service.AutoShopInstance.AddVehicle(new Vehicle("Peugeot", "106", 1999, 80, 30000, FuelType.Diesel, Gearbox.Automatic, owner1, "red", "very good", "CA 1234 AC", repairsCar1, Status.Accepted)); Service.AutoShopInstance.AddVehicle(new Vehicle("BMW", "5", 2002, 80, 350000, FuelType.Electric, Gearbox.SemiAutomatic, owner2, "red", "no comments", "PA 8750 HA", repairsCar2, Status.Accepted)); Service.AutoShopInstance.AddVehicle(new Vehicle("Mercedes", "SLK", 2010, 140, 110000, FuelType.Electric, Gearbox.SemiAutomatic, owner2, "red", "no comments", "A 8993 MM", repairsCar2, Status.Accepted)); // Distributors Address distributor1Address = new Address("Sofia", "2000", "j.k. Studentski grad", "ul. Vladishka", 23, "no comment"); Address distributor2Address = new Address("Sofia", "2000", "Obelq", "ul. Hristo Smirnenski", 55, "no comment"); Address distributor3Address = new Address("Sofia", "2000", "j.k. Dianabat", "ul. G.M.Dimitrov", 111, "no comment"); Service.AutoShopInstance.AddDistributor(new Distributor("MotoPfohe Ltd", distributor1Address, "089 901 5632", "*****@*****.**", "no comment", parts)); Service.AutoShopInstance.AddDistributor(new Distributor("BetterCars Ltd", distributor2Address, "089 598 8915", "*****@*****.**", "no comment", parts)); Service.AutoShopInstance.AddDistributor(new Distributor("PartsForPeople Ltd", distributor3Address, "088 991 5987", "*****@*****.**", "no comment", parts)); // Employees Address employee1Address = new Address("Sofia", "2000", "j.k. Mladost 1", "ul. Aleksander Batemberg", 39, "no comment"); Address employee2Address = new Address("Sofia", "2000", "j.k. Lulin", "ul. Todor Kableshkov", 24, "no comment"); Service.AutoShopInstance.AddEmployee(new Employee( "Marin Ivanov", employee1Address, "0883442233", "*****@*****.**", "no comment", 500, Position.Accountant)); Service.AutoShopInstance.AddEmployee(new Employee( "Kiril Manolov", employee2Address, "0883212233", "*****@*****.**", "no comment", 300, Position.JunorMechanic)); }