Ejemplo n.º 1
0
        internal static bool EntitySelection <TEntity>(List <TEntity> entities, out TEntity entity, int tabCount = 0) where TEntity : Entity
        {
            if (entities.Count == 0)
            {
                entity = null;
                return(false);
            }
            do
            {
                CommonClientFunctions.PrintEntities(entities, tabCount);
                Console.WriteLine($"{entities.Count + 1}) Cancel");
                var success = Int32.TryParse(Console.ReadLine(), out int input);

                if (input > 0 && input <= entities.Count && success)
                {
                    entity = entities[input - 1];
                    return(true);
                }
                else if (input == entities.Count + 1)
                {
                    entity = null;
                    return(true);
                }
            } while (true);
        }