private void fillVehicleArguments(ArgumentConsumersContainer i_VehicleArgumentsContainer, VehiclesFactory.eVehicleType i_VehicleType) { Console.WriteLine("We are going to add {0} to garage, please enter the following information: ", i_VehicleType); foreach (KeyValuePair <string, ArgumentConsumer> argument in i_VehicleArgumentsContainer.GetConsumers) { StringBuilder menuBuilder = new StringBuilder(); menuBuilder.AppendFormat("{0}{1}", argument.Value.GetMessage, Environment.NewLine); if (argument.Value.GetBounds != null) { menuBuilder.AppendLine("Bounds are:"); int? minValueNullable = argument.Value.GetBounds.MinValue; int? maxValueIntNullable = argument.Value.GetBounds.MaxValue; float? maxValueFloatNullable = argument.Value.GetBounds.MaxValueFloat; string maxValue = string.Empty; if (minValueNullable != null) { string minValue = minValueNullable.ToString(); menuBuilder.AppendFormat("Minimum value: {0}, ", minValue); } if (maxValueFloatNullable != null) { maxValue = maxValueFloatNullable.ToString(); } if (maxValueIntNullable != null) { maxValue = maxValueIntNullable.ToString(); } menuBuilder.AppendFormat("Maximum value: {0}{1}", maxValue, Environment.NewLine); } if (argument.Value.GetOptionalValues.Length != 0) { menuBuilder.AppendLine("Available values are:"); foreach (string optionalValue in argument.Value.GetOptionalValues) { menuBuilder.AppendLine(optionalValue); } } Console.WriteLine(menuBuilder.ToString()); string userInput = Console.ReadLine(); //TryParseArgument(userInput, argument); //give each argument and user input and try to parse - success = put the new type after parse in argument.ValueOfUser/ fails = FormatException } }
private void addVehicleToGarage() { showAvailableVehicles(); VehiclesFactory.eVehicleType vehicleType = selectVehicleType(); Client client = getClientInformation(); ArgumentConsumersContainer vehicleArgumentsContainer = VehiclesFactory.GetVehicleArguments(vehicleType); fillVehicleArguments(vehicleArgumentsContainer, vehicleType); Vehicle vehicleToAdd = VehiclesFactory.GetVehicle(vehicleType, vehicleArgumentsContainer); ClientVehicle clientVehicle = new ClientVehicle(client, vehicleToAdd, ClientVehicle.eClientVehicleStatus.InRepair); bool didCarEnterTheGarage = r_Garage.AddVehicleToGarage(clientVehicle); printMessageToConsole( didCarEnterTheGarage == true ? eMessageToPrint.CarHasEnteredTheGarage : eMessageToPrint.CarIsAlreadyInTheGarage); }