예제 #1
0
        public static void addAccount(string player, string username, string password, string server, string name)
        {
            Account account = new Account(player, username, password, server, name);

            if (account.failed)
            {
                MessageBox.Show("Something went wrong");
                return;
            }
            if (AccountListHandler.puuIds.Contains(account.puuId))
            {
                MessageBox.Show("Account already added");
                return;
            }
            AccountListHandler.puuIds.Add(account.puuId);


            if (!AccountListHandler.accounts.ContainsKey(player))                                 // If player not present
            {
                AccountListHandler.accounts[player] = new Dictionary <string, List <Account> >(); // Add <player, server dictionary> to dictionary
            }

            if (!AccountListHandler.accounts[player].ContainsKey(server))           // If server not present in player
            {
                AccountListHandler.accounts[player][server] = new List <Account>(); // Add empty server list<account> to player
            }

            AccountListHandler.accounts[player][server].Add(account); // Add account to server


            AccountListHandler.serializeAllAccounts();
        }
예제 #2
0
        public static string deleteAccount(Account account)
        {
            if (account != null)
            {
                string player = account.player;
                string server = account.server;

                AccountListHandler.accounts[player][server].Remove(account);
                if (AccountListHandler.accounts[player][server].Count == 0)
                {
                    AccountListHandler.accounts[player].Remove(server);
                }
                if (AccountListHandler.accounts[player].Count == 0)
                {
                    AccountListHandler.accounts.Remove(player);
                }

                AccountListHandler.serializeAllAccounts();

                return(account.name);
            }
            return(null);
        }