Пример #1
0
        public Bitmap GetUserIcon(User user)
        {
            if (iconCache.Contains(user.Id))
            {
                var icon = iconCache[user.Id] as Bitmap;
                if (icon != null)
                    return icon;
            }

            user.GetIcon().ThenOnUI(image => {
                var policy = new CacheItemPolicy {
                    SlidingExpiration = TimeSpan.FromMinutes (60)
                };
                iconCache.Set(user.Id, image, policy);
                foreach (var channel in this.Channels)
                {
                    if (channel.Users.Any(r => r.Id == user.Id))
                    {
                        channel.TriggerUserIconChanged(new UserImageEventArgs(user, DateTimeOffset.Now, image));
                    }
                }
            });

            return User.DefaultUserIcon;
        }