file scoped namespaces (#565)

This commit is contained in:
Aleh Khantsevich
2025-02-16 11:54:23 +01:00
committed by GitHub
parent cf9869b71e
commit 3ddc1a6229
617 changed files with 32107 additions and 32721 deletions
@@ -4,28 +4,27 @@ using System.Threading.Tasks;
using Windows.Storage;
using Wino.Core.Domain.Models.Common;
namespace Wino.Core.UWP.Extensions
namespace Wino.Core.UWP.Extensions;
public static class StorageFileExtensions
{
public static class StorageFileExtensions
public static async Task<SharedFile> ToSharedFileAsync(this Windows.Storage.StorageFile storageFile)
{
public static async Task<SharedFile> ToSharedFileAsync(this Windows.Storage.StorageFile storageFile)
var content = await storageFile.ToByteArrayAsync();
return new SharedFile(storageFile.Path, content);
}
public static async Task<byte[]> ToByteArrayAsync(this StorageFile file)
{
if (file == null)
throw new ArgumentNullException(nameof(file));
using (var stream = await file.OpenReadAsync())
using (var memoryStream = new MemoryStream())
{
var content = await storageFile.ToByteArrayAsync();
return new SharedFile(storageFile.Path, content);
}
public static async Task<byte[]> ToByteArrayAsync(this StorageFile file)
{
if (file == null)
throw new ArgumentNullException(nameof(file));
using (var stream = await file.OpenReadAsync())
using (var memoryStream = new MemoryStream())
{
await stream.AsStreamForRead().CopyToAsync(memoryStream);
return memoryStream.ToArray();
}
await stream.AsStreamForRead().CopyToAsync(memoryStream);
return memoryStream.ToArray();
}
}
}