TShockAPI.DB.UserManager.AddUser C# (CSharp) Метод

AddUser() публичный Метод

Adds a given username to the database
public AddUser ( User user ) : void
user User User user
Результат void
        public void AddUser(User user)
        {
            if (!TShock.Groups.GroupExists(user.Group))
                throw new GroupNotExistsException(user.Group);

            int ret;
            try
            {
                ret = _database.Query("INSERT INTO Users (Username, Password, UUID, UserGroup, Registered) VALUES (@0, @1, @2, @3, @4);", user.Name,
                    user.Password, user.UUID, user.Group, DateTime.UtcNow.ToString("s"));
            }
            catch (Exception ex)
            {
                // Detect duplicate user using a regexp as Sqlite doesn't have well structured exceptions
                if (Regex.IsMatch(ex.Message, "Username.*not unique"))
                    throw new UserExistsException(user.Name);
                throw new UserManagerException("AddUser SQL returned an error (" + ex.Message + ")", ex);
            }

            if (1 > ret)
                throw new UserExistsException(user.Name);

            Hooks.AccountHooks.OnAccountCreate(user);
        }