//请在APP起动的时候调用 public async static void TryInit() { var options = new DisplayImageOptions.Builder() .CacheInMemory(false) .CacheOnDisk(true) .Build(); var root = ApplicationData.Current.LocalFolder; //图标 var iconDir = await root.CreateFolderAsync("icon", CreationCollisionOption.OpenIfExists); Icon = ImageLoader.Register("icon", new ImageLoaderConfiguration.Builder() .ThreadPoolSize(5) .TasksProcessingOrder(QueueProcessingType.FIFO) .DiskCache(new DiskCache(iconDir, new Md5FileNameGenerator())) .DefaultDisplayImageOptions(options) .ImageDownloader(new HttpClientImageDownloader()) .Build()); //像册 var photoDir = await root.CreateFolderAsync("photo", CreationCollisionOption.OpenIfExists); Photo = ImageLoader.Register("photo", new ImageLoaderConfiguration.Builder() .ThreadPoolSize(5) .TasksProcessingOrder(QueueProcessingType.FIFO) .DiskCache(new DiskCache(photoDir, new Md5FileNameGenerator())) .DefaultDisplayImageOptions(options) .ImageDownloader(new HttpClientImageDownloaderEx()) //使用自定义扩展支持高级用法 .Build()); }
public ImageLoader CurrentLoader() { if (_CurrentLoader == null) { if (string.IsNullOrEmpty(Loader)) _CurrentLoader = ImageLoader.Default; else _CurrentLoader = ImageLoader.Get(Loader); } return _CurrentLoader; }
public static ImageLoader Register(string key, ImageLoaderConfiguration config) { var temp = new ImageLoader().Init(config); _libs[key] = temp; return temp; }