示例#1
0
        public async Task <object> GetImage(Uri uri)
        {
            var filename = Uri.EscapeDataString(uri.AbsoluteUri);

            if (HasLocallyCachedCopy(uri))
            {
                using (var o = await OpenStorage(filename, PCLStorage.FileAccess.Read))
                {
                    return(LoadImage(o));
                }
            }
            else
            {
                using (var d = http.Get(uri))
                    using (var o = await OpenStorage(filename, PCLStorage.FileAccess.ReadAndWrite))
                    {
                        d.CopyTo(o);
                    }

                using (var o = await OpenStorage(filename, PCLStorage.FileAccess.Read))
                {
                    return(LoadImage(o));
                }
            }
        }
示例#2
0
        public object GetImage(Uri uri)
        {
            var filename = Uri.EscapeDataString(uri.AbsoluteUri);

            if (HasLocallyCachedCopy(uri))
            {
                using (var o = OpenStorage(filename, FileMode.Open))
                    return(LoadImage(o));
            }
            else
            {
                using (var d = http.Get(uri))
                    using (var o = OpenStorage(filename, FileMode.Create))
                        d.CopyTo(o);

                using (var o = OpenStorage(filename, FileMode.Open))
                    return(LoadImage(o));
            }
        }