示例#1
0
    private static void ProcessCommand(string command)
    {
        string[] data = command.Split();

        if (command.StartsWith("login"))
        {
            userManager.LogIn(data[1]);
            textEditor.Login(data[1]);
        }
        else if (command.StartsWith("logout"))
        {
            userManager.LogOut(data[1]);
            textEditor.Logout(data[1]);
        }
        else if (command.StartsWith("users"))
        {
            string prefix = "";

            if (data.Length > 1)
            {
                prefix = data[1];
            }

            IEnumerable <string> users = textEditor.Users(prefix);
            PrintAllUsers(users);
        }
        else
        {
            string username = data[0];

            if (userManager.IsLoged(username))
            {
                ProcessUserCommand(data);
            }
        }
    }