示例#1
0
        private async Task <ImageSource> SetImage()
        {
            var imagePath = Result.IcoPath;

            if (string.IsNullOrEmpty(imagePath) && Result.Icon != null)
            {
                try
                {
                    return(Result.Icon());
                }
                catch (Exception e)
                {
                    Log.Exception($"|ResultViewModel.Image|IcoPath is empty and exception when calling Icon() for result <{Result.Title}> of plugin <{Result.PluginDirectory}>", e);
                    imagePath = Constant.MissingImgIcon;
                }
            }

            if (ImageLoader.CacheContainImage(imagePath))
            {
                // will get here either when icoPath has value\icon delegate is null\when had exception in delegate
                return(ImageLoader.Load(imagePath));
            }
            else
            {
                return(await Task.Run(() => ImageLoader.Load(imagePath)));
            }
        }