Пример #1
0
        public static void Create(string name, string password, Userlevel level)
        {
            User user = GetByName(name);
            if (user != null)
                throw new UserAlreadyExistsException("A user with the name '" + name + "' already exists.");

            user = new User();
            user.name = name;
            user.password = password;
            user.level = level;
            Base.Users.Add(user);
            Save(Base.Users);
        }
Пример #2
0
        public static List<User> Load()
        {
            List<User> users = new List<User>();

            XmlDocument xmlDoc = new XmlDocument();
            xmlDoc.Load(Base.Configuration.PhysicalApplicationPath + "\\App_Data\\Users.xml");

            foreach (XmlElement xmlElement in xmlDoc["Dreadnought"].GetElementsByTagName("User")) {
                User user = new User();
                user.name = xmlElement.Attributes["Name"].Value;
                user.password = xmlElement.Attributes["Password"].Value;
                user.level = (Userlevel)Enum.Parse(typeof(Userlevel), xmlElement.Attributes["Level"].Value);
                users.Add(user);
            }

            return users;
        }