Exemple #1
0
        private static RayPortUser GetRayPortUserToModify()
        {
            var repo          = new RayConfigRepository();
            var rayPortsUsers = repo.GetRayPortsUsers();

            ConsoleConfigDisplayer.DisplayRayPortUsers(
                rayPortsUsers, displayUserIndex:true, intend: 2);

            int?index = InputHelper.TryGetNumberInput(
                inputRange: new Tuple <int, int>(1, rayPortsUsers.Count)) - 1;

            if (index == null)
            {
                return(GetRayPortUserToModify());
            }
            ;

            return(rayPortsUsers[index.Value]);
        }
Exemple #2
0
        private void ShowRayPortsUsersAndGetRayPortUserToDelete()
        {
            IList <RayPortUser> rayPortsUsers = repo.GetRayPortsUsers();

            Console.Clear();

            ConsoleConfigDisplayer.DisplayRayPortUsers(
                rayPortsUsers, displayUserIndex: true, intend: 2);

            int?ch = InputHelper.TryGetNumberInput(
                "输入索引来选择要删除的用户", inputRange: new Tuple <int, int>(1, rayPortsUsers.Count));

            if (ch == null)
            {
                throw new Exception($"输入错误, 输入范围必须是1-{rayPortsUsers.Count}的数字");
            }

            rayPortUserToDelete = rayPortsUsers[ch.Value - 1];
        }