• Welcome to Valhalla Legends Archive.
 

[C#] User Management

Started by Smarter, December 05, 2007, 08:33 AM

Previous topic - Next topic

Smarter

I got bored and created a user management system if anyone would like to use it:

UserList.cs Code:

    public class Userlist
    {
        private Dictionary<string, User> userList = new Dictionary<string, User>();

        public Userlist()
        {

        }

        public void addUser(string Username, string Client, int Ping, int Flags, string Statstring)
        {
            userList.Add(Username, new User(Username, Client, Ping, Flags, Statstring));
        }
        public User getUser(string userName)
        {
            return userList[userName];
        }
    }

    public class User
    {
        private string m_username, m_client, m_statstring;
        private int m_ping, m_flags;

        public User(string Username, string Client, int Ping, int Flags, string Statstring)
        {
            m_username = Username;
            m_client = Client;
            m_ping = Ping;
            m_flags = Flags;
            m_statstring = Statstring;
        }

        public string Username { get { return m_username; } }
        public string Client { get { return m_client; } }
        public int Ping { get { return m_ping; } }
        public int Flags { get { return m_flags; } }
        public string Statstring { get { return m_statstring; } }
    }


Usage Code:

            Userlist userlist = new Userlist();
            userlist.addUser("Smarter", "SEXP", 0, 0, "123");
            User u = userlist.getUser("Smarter");
            MessageBox.Show("Username: " + u.Username + "\n" +
                "Client: " + u.Client + "\n" + "Ping: " + u.Ping + "\n" + "Flags: " + u.Flags +
                "\n" + "Statstring: " + u.Statstring + "\n");


Enjoy, and feel free to post comments.
Since '99

BrutalNet.Net