Example #1
0
        /// <summary>
        /// Get the image bytes asynchronously. Must be called from the main thread,
        /// as the <see cref="DataPath"/> is accessed and Realm can only be used from the main
        /// thread. If you need to access the data from another thread, call
        /// <see cref="PrepareImageLoad"/> on the main thread and then call
        /// <see cref="PreparedImageLoad.GetDataAsync"/> on it.
        /// </summary>
        /// <returns></returns>
        public virtual async Task <byte[]> GetDataAsync()
        {
            var dataPath = DataPath; // DO NOT INLINE! See method documentation.

            Debug2.Assert(dataPath != null, $"dataPath is null for media with REST ID {IdForRestApi}");
            return(await MediaCache.GetBytesAsync(
                       IdForRestApi,
                       async() => await fileManager.ReadFromDiskAsync(dataPath)
                       ));
        }
Example #2
0
 public byte[] GetDataBlocking() => MediaCache.GetBytes(
     IdForRestApi,
     () => fileManager.ReadFromDisk(DataPath)
     );
Example #3
0
 public async Task <byte[]> GetDataAsync() => await MediaCache.GetBytesAsync(
     IdForRestApi,
     async() => await fileManager.ReadFromDiskAsync(DataPath)
     );