public User GetUser(long userId, bool forceUpdate = false) { if (forceUpdate || !_usersCache.ContainsKey(userId)) { var user = _serviceProvider.GetService <IGroupApiProvider>().GetAdminApi().Users.Get(new[] { userId }, ProfileFields.All); _usersCache[userId] = new CacheableEntry <User>(user[0]); } return(_usersCache[userId].Entry); }
public System.Drawing.Image GetUserAvatar(long userId, bool forceUpdate = false) { if (forceUpdate || !_userAvatarsCache.ContainsKey(userId)) { var user = GetUser(userId, forceUpdate); var url = user.PhotoPreviews.GetMaxPhotoUrl(); var stream = _serviceProvider.GetService <IRestClient>().GetStream(url); _userAvatarsCache[userId] = new CacheableEntry <System.Drawing.Image>(System.Drawing.Image.FromStream(stream)); } return((System.Drawing.Image)_userAvatarsCache[userId].Entry.Clone()); }