public static Task <byte[]> readAsBytes(this File f) { // X:\jsc.svn\examples\javascript\io\WebApplicationSelectingFile\WebApplicationSelectingFile\Application.cs // X:\jsc.svn\examples\javascript\io\DropFileForMD5Experiment\DropFileForMD5Experiment\Application.cs var y = new TaskCompletionSource <byte[]>(); var x = new FileReader(); //Console.WriteLine("readAsText FileReader"); x.onload = new Action( delegate { var a = (ArrayBuffer)x.result; var u8c = new Uint8ClampedArray(array: a); // X:\jsc.svn\core\ScriptCoreLib\JavaScript\BCLImplementation\System\Net\WebClient.cs y.SetResult((byte[])u8c); } ); // partial build? // move to .Async? x.readAsArrayBuffer(f); //Console.WriteLine("readAsText FileReader readAsText"); return(y.Task); }
public static Task<byte[]> readAsBytes(this File f) { // X:\jsc.svn\examples\javascript\io\WebApplicationSelectingFile\WebApplicationSelectingFile\Application.cs // X:\jsc.svn\examples\javascript\io\DropFileForMD5Experiment\DropFileForMD5Experiment\Application.cs var y = new TaskCompletionSource<byte[]>(); var x = new FileReader(); //Console.WriteLine("readAsText FileReader"); x.onload = new Action( delegate { var a = (ArrayBuffer)x.result; var u8c = new Uint8ClampedArray(array: a); // X:\jsc.svn\core\ScriptCoreLib\JavaScript\BCLImplementation\System\Net\WebClient.cs y.SetResult((byte[])u8c); } ); // partial build? // move to .Async? x.readAsArrayBuffer(f); //Console.WriteLine("readAsText FileReader readAsText"); return y.Task; }