using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApp.Menu { internal abstract partial class Entry { public class EntryStep { private Type _entryType; public string Description { get; private set; } public string? Input { get; private set; } internal EntryStep(string description, Type type) { Description = description; Input = null; _entryType = type; } public object GetEntry() { Input = Console.ReadLine(); if (Input is null) throw new ArgumentException("Error: input is null."); try { if (_entryType == typeof(string)) return Input; if (_entryType == typeof(int)) return Int32.Parse(Input); if (_entryType == typeof(DateTime)) return DateTime.Parse(Input); } catch (FormatException fe) { Console.Error.WriteLine(fe); } throw new NotImplementedException("Error: parse of this type is not implemented."); } } } }