/// <summary> /// GetAssetSize /// Return the current asset size on disk: audio chunks, video chunks and manifest /// </summary> public async Task <ulong> GetAssetSize(ManifestCache cache) { ulong val = 0; string path = string.Empty; path = Path.Combine(Path.Combine(root, cache.StoragePath), manifestFileName); if (!string.IsNullOrEmpty(path)) { val += await GetFileSize(path); } using (var releaser = await internalVideoDiskLock.ReaderLockAsync()) { path = Path.Combine(Path.Combine(root, cache.StoragePath), videoIndexFileName); if (!string.IsNullOrEmpty(path)) { val += await GetFileSize(path); } path = Path.Combine(Path.Combine(root, cache.StoragePath), videoContentFileName); if (!string.IsNullOrEmpty(path)) { val += await GetFileSize(path); } } using (var releaser = await internalAudioDiskLock.ReaderLockAsync()) { path = Path.Combine(Path.Combine(root, cache.StoragePath), audioIndexFileName); if (!string.IsNullOrEmpty(path)) { val += await GetFileSize(path); } path = Path.Combine(Path.Combine(root, cache.StoragePath), audioContentFileName); if (!string.IsNullOrEmpty(path)) { val += await GetFileSize(path); } } return(val); }
/// <summary> Get object from isolated storage file.</summary> /// <param name="fullpath"> file name to retreive</param> /// <param name="type"> type of object to read</param> /// <returns> a <c>object</c> instance, or null if the operation failed.</returns> private async Task <object> GetObjectByType(string filepath, Type type) { object retVal = null; try { using (var releaser = await internalManifestDiskLock.ReaderLockAsync()) { System.Diagnostics.Debug.WriteLine(string.Format("{0:d/M/yyyy HH:mm:ss.fff}", DateTime.Now) + " internalManifestDiskLock Reader Enter for Uri: " + filepath.ToString()); byte[] bytes = await Restore(filepath); if (bytes != null) { try { using (MemoryStream ms = new MemoryStream(bytes)) { if (ms != null) { System.Runtime.Serialization.DataContractSerializer ser = new System.Runtime.Serialization.DataContractSerializer(type); retVal = ser.ReadObject(ms); } } } catch (Exception e) { System.Diagnostics.Debug.WriteLine(string.Format("{0:d/M/yyyy HH:mm:ss.fff}", DateTime.Now) + " internalManifestDiskLock Reader Exception for Uri: " + filepath.ToString() + " Exception: " + e.Message); } } System.Diagnostics.Debug.WriteLine(string.Format("{0:d/M/yyyy HH:mm:ss.fff}", DateTime.Now) + " internalManifestDiskLock Reader Exit for Uri: " + filepath.ToString()); } } catch (Exception) { } return(retVal); }