mirror of
https://github.com/wismna/ModernKeePass.git
synced 2025-10-03 23:50:18 -04:00
WIP KeePassLibPCL - problem with awaitables
This commit is contained in:
17
ModernKeePassLib/Utility/StreamExtensions.cs
Normal file
17
ModernKeePassLib/Utility/StreamExtensions.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using System.IO;
|
||||
using Windows.Storage.Streams;
|
||||
|
||||
namespace ModernKeePassLibPCL.Utility
|
||||
{
|
||||
public static class StreamExtensions
|
||||
{
|
||||
public static Stream AsStream(this IRandomAccessStream inputStream)
|
||||
{
|
||||
var reader = new DataReader(inputStream.GetInputStreamAt(0));
|
||||
var bytes = new byte[inputStream.Size];
|
||||
reader.LoadAsync((uint)inputStream.Size).GetResults();
|
||||
reader.ReadBytes(bytes);
|
||||
return new MemoryStream(bytes);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user