コード例 #1
0
        /// <summary>
        ///获取当前用户的ID。
        ///throws<see cref=“shareplatformException”/>if<see cref=“ishareplatformsession.userid”/>为空。
        /// </summary>
        /// <param name="session">会话对象。</param>
        /// <returns>当前用户的ID。</returns>
        public static string GetUserId(this ISharePlatformSession session)
        {
            if (string.IsNullOrWhiteSpace(session.UserId))
            {
                throw new SharePlatformException("session.userid为空!可能用户没有登录。");
            }

            return(session.UserId);
        }
コード例 #2
0
 /// <summary>
 /// Creates <see cref="UserIdentifier"/> from given session.
 /// Returns null if <see cref="ISharePlatformSession.UserId"/> is null.
 /// </summary>
 /// <param name="session">The session.</param>
 public static UserIdentifier ToUserIdentifier(this ISharePlatformSession session)
 {
     return(session.UserId == null
         ? null
         : new UserIdentifier(session.GetUserId()));
 }