/// <summary> /// 声明用户登入 /// </summary> /// <param name="db">数据库连接对象</param> /// <param name="userId">用户信息的存储指针</param> /// <returns>返回身份标识</returns> public static string AddInfo(IModelToDbContextOfAuthor db, int userId) { lock (infos) { RemoveInfo(userId); AuthorLoginInfo info = new AuthorLoginInfo(db, userId); CallEvent(Logining, info); infos.Add(info); CallEvent(Logined, info); return info.Token; } }
/// <summary> /// 触发事件 /// </summary> /// <param name="_event">事件</param> /// <param name="info">数据集</param> static void CallEvent(Action<AuthorLoginInfo> _event, AuthorLoginInfo info) { if (_event != null) { _event(info); } }
static void RemoveCallback(AuthorLoginInfo info) { RemoveCallback(info.UserId); }