Ejemplo n.º 1
0
 /// <summary>
 /// 非线程安全的
 /// </summary>
 /// <returns></returns>
 public static ImageCache CreateInstance()
 {
     if (_instance == null)
     {
         lock (lockHelper)
         {
             if (_instance == null)
             {
                 _instance = new ImageCache();
             }
         }
     }
     return(_instance);
 }
Ejemplo n.º 2
0
        private async void ShareWindow_WeChatShareClick(object sender, RoutedEventArgs e)
        {
            var cache = ImageCache.CreateInstance();
            var uri   = await cache.GetImageSourceFromUrlAsync(story.Images[0]);

            var file = await StorageFile.GetFileFromApplicationUriAsync(uri);

            using (var stream = await file.OpenReadAsync())
            {
                var pic = new byte[stream.Size];
                await stream.AsStream().ReadAsync(pic, 0, pic.Length);

                WeChatClient client = new WeChatClient();
                client.ShareLink(shareUrl, title, $"{title}(分享自 @知乎日报 App)", pic);
            }
        }