Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public interface ICommand
- {
- string LogIn(string data);
- string GetChars(string data);
- }
- public class Commands : ICommand
- {
- public string LogIn(string data)
- {
- TableManager tableManager = new TableManager();
- User user = new User();
- var logpass = Separator.Data;
- var chars = tableManager.GetTableInfo("*", "Chars", 1);
- string reply;
- if (user.loggedin(logpass[0], logpass[1]))
- {
- reply = "Пользователь существует. Список персонажей: " + chars;
- }
- else
- {
- reply = "Такого пользователя не существует!";
- }
- return reply;
- }
- public string GetChars(string data)
- {
- return "хуй" + data;
- }
- }
- public class CommandDictionary
- {
- private ICommand _commands;
- private Dictionary<string, Func<string, string>> _dictionary;
- public CommandDictionary(ICommand commands)
- {
- _commands = commands;
- _dictionary = CreateDictionary();
- }
- public Dictionary<string, Func<string, string>> CreateDictionary()
- {
- var dictionary = new Dictionary<string, Func<string, string>>
- {
- {"LogIn", _commands.LogIn},
- {"GetChars", _commands.GetChars}
- };
- return dictionary;
- }
- public string RunCommand(string name, string value)
- {
- if (_dictionary.ContainsKey(name))
- {
- return _dictionary[name].Invoke(value);
- }
- return string.Empty;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement