Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p><a href="http://canbilgin.wordpress.com/2012/06/06/how-to-convert-byte-array-to-irandomaccessstream/" rel="nofollow">How to Convert byte Array to IRandomAccessStream</a></p> <p>I've found this blog article, hopefully this realization of <code>IRandomAccessStream</code> can be a starting point for you.</p> <pre><code>class MemoryRandomAccessStream : IRandomAccessStream { private Stream m_InternalStream; public MemoryRandomAccessStream(Stream stream) { this.m_InternalStream = stream; } public MemoryRandomAccessStream(byte[] bytes) { this.m_InternalStream = new MemoryStream(bytes); } public IInputStream GetInputStreamAt(ulong position) { this.m_InternalStream.Seek((long)position, SeekOrigin.Begin); return this.m_InternalStream.AsInputStream(); } public IOutputStream GetOutputStreamAt(ulong position) { this.m_InternalStream.Seek((long)position, SeekOrigin.Begin); return this.m_InternalStream.AsOutputStream(); } public ulong Size { get { return (ulong)this.m_InternalStream.Length; } set { this.m_InternalStream.SetLength((long)value); } } public bool CanRead { get { return true; } } public bool CanWrite { get { return true; } } public IRandomAccessStream CloneStream() { throw new NotSupportedException(); } public ulong Position { get { return (ulong)this.m_InternalStream.Position; } } public void Seek(ulong position) { this.m_InternalStream.Seek((long)position, 0); } public void Dispose() { this.m_InternalStream.Dispose(); } public Windows.Foundation.IAsyncOperationWithProgress&lt;IBuffer, uint&gt; ReadAsync(IBuffer buffer, uint count, InputStreamOptions options) { var inputStream = this.GetInputStreamAt(0); return inputStream.ReadAsync(buffer, count, options); } public Windows.Foundation.IAsyncOperation&lt;bool&gt; FlushAsync() { var outputStream = this.GetOutputStreamAt(0); return outputStream.FlushAsync(); } public Windows.Foundation.IAsyncOperationWithProgress&lt;uint, uint&gt; WriteAsync(IBuffer buffer) { var outputStream = this.GetOutputStreamAt(0); return outputStream.WriteAsync(buffer); } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload