0
我想要實現委託給另一個IInputStream的IInputStream並返回給用戶,這樣的前處理讀取的數據:如何在IInputStream接口中包裝Windows.Storage.Streams.IInputStream?
using System;
using Windows.Storage.Streams;
using Org.BouncyCastle.Crypto;
using Org.BouncyCastle.Crypto.Engines;
using Org.BouncyCastle.Crypto.Parameters;
namespace Core.Crypto {
public class RC4InputStream : IInputStream {
public RC4InputStream(IInputStream stream, byte[] readKey) {
_stream = stream;
_cipher = new RC4Engine();
_cipher.Init(false, new KeyParameter(readKey));
}
public Windows.Foundation.IAsyncOperationWithProgress<IBuffer, uint> ReadAsync(IBuffer buffer, uint count, InputStreamOptions options)
{
var op = _stream.ReadAsync(buffer, count, options);
// Somehow magically hook up something so that I can call _cipher.ProcessBytes(...)
return op;
}
private readonly IInputStream _stream;
private readonly IStreamCipher _cipher;
}
}
我有我一直沒能回答通過搜索兩個不同的問題在互聯網絡的浩瀚:什麼是連鎖的最佳途徑另一個操作運行下放後ReadAsync()(我可以用「等待」,也許
- 創建一個新的IAsyncOperation使用AsyncInfo,但我不知道該怎麼連接進度記者等)
- 如何訪問「IBuffer」背後的數據?