public Stream EchoStream(Stream data) { Console.WriteLine($"[EchoStream]...Received length:{data.Length}, {Helper.ReadStr(data)}...Send TestFile.txt"); var stream = File.Open(Helper.GetTestFilePath(), FileMode.Open, FileAccess.Read, FileShare.ReadWrite); return(stream); }
public async Task <ComplexStream> ComplexCallAsync(CustomObj obj, string p1, Stream stream, Func <CustomCallbackObj, Task> cb, CancellationToken token) { Console.WriteLine($"[ComplexCallAsync]...receive:{obj}, p1:{p1}, streamLength:{stream.Length}"); for (var i = 1; i <= 3; i++) { Console.Write($"{i}, "); await cb(new CustomCallbackObj { Progress = i }); await Task.Delay(1000, token); } var ret = new ComplexStream { Stream = File.Open(Helper.GetTestFilePath(), FileMode.Open, FileAccess.Read, FileShare.ReadWrite), StreamName = "TestFile.txt", InnerObj = new InnerObj { CustomObj = new CustomObj { Name = NameEnum.John }, P1 = "中文p1!@#$%^&*()_+\"\":?~!@#$" } }; return(ret); }
public Stream GetStream() { Console.WriteLine("[GetStream]...Send TestFile.txt"); var stream = File.Open(Helper.GetTestFilePath(), FileMode.Open, FileAccess.Read, FileShare.ReadWrite); return(stream); }
public ComplexStream GetComplexStream() { Console.WriteLine("[GetComplexStream]...Send TestFile.txt...this is other info"); return(new ComplexStream { Stream = File.Open(Helper.GetTestFilePath(), FileMode.Open, FileAccess.Read, FileShare.ReadWrite), OtherInfo = "this is other info" }); }
private static void Test_EchoStream() { using (var stream = File.Open(Helper.GetTestFilePath(), FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) { Console.Write("[EchoStream]...Send TestFile.txt..."); var data = _proxy.EchoStream(stream); Console.WriteLine($"Received length:{data.Length}, {Helper.ReadStr(data)}"); } }
private static async Task Test_EchoStreamAsync() { using (var stream = File.Open(Helper.GetTestFilePath(), FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) { Console.Write("[EchoStreamAsync]...Send TestFile.txt..."); var data = await _proxyAsync.EchoStreamAsync(stream); Console.WriteLine($"Received length:{stream.Length}, {Helper.ReadStr(data)}"); } }
private static async Task Test_ComplexCallAsync() { using (var stream = File.Open(Helper.GetTestFilePath(), FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) { Console.Write("[ComplexCallAsync]...Send TestFile.txt..."); var complexStream = await _c1.Proxy.ComplexCallAsync( new CustomObj { Date = DateTime.Now, Name = "ComplexCall" }, stream, async i => Console.Write(", " + i.Progress), default); using (var stream2 = complexStream.Stream) Console.Write($", receive length:{stream.Length}, {Helper.ReadStr(stream2)}"); Console.WriteLine($", otherInfo:{complexStream.OtherInfo}"); } }
public async Task <Ret> Call(InParam p, int i, Stream stream, Func <int, Task> progs, CancellationToken token) { Console.WriteLine($"{p}, {i}, {Helper.ReadStr(stream)}"); for (var i1 = 0; i1 < 3; i1++) { await progs(i1); await Task.Delay(100, token); } return(new Ret { Stream = File.OpenRead(Helper.GetTestFilePath()), P1 = "return p1" }); }
public async Task <ComplexStream> ComplexCallAsync(CustomObj obj, Stream data, Func <CustomCallbackObj, Task> cb, CancellationToken token) { Console.Write($"[ComplexCallAsync]...Received length:{data.Length}, {Helper.ReadStr(data)}, "); for (var i = 1; i <= 3; i++) { Console.Write($"{i}, "); await cb(new CustomCallbackObj { Progress = i }); await Task.Delay(100, token); } Console.WriteLine("...Send TestFile.txt"); return(new ComplexStream { Stream = File.Open(Helper.GetTestFilePath(), FileMode.Open, FileAccess.Read, FileShare.ReadWrite), OtherInfo = "this is other info" }); }
public ComplexStream ComplexCall(CustomObj obj, Stream data, Func <CustomCallbackObj, Task> cb) { Console.Write($"[ComplexCall]...Received length:{data.Length}, {Helper.ReadStr(data)}, "); for (var i = 1; i <= 3; i++) { Console.Write($"{i}, "); cb(new CustomCallbackObj { Progress = i }); Task.Delay(100).Wait(); } Console.WriteLine("...Send TestFile.txt"); return(new ComplexStream { Stream = File.Open(Helper.GetTestFilePath(), FileMode.Open, FileAccess.Read, FileShare.ReadWrite), OtherInfo = "this is other info" }); }
public async Task StartAsync(CancellationToken cancellationToken) { try { var ret = await _s1.Call( new InParam {P1 = "123"}, 100, File.OpenRead(Helper.GetTestFilePath()), async i => Console.WriteLine(i), CancellationToken.None); Console.WriteLine($"ret:{ret.P1}, {Helper.ReadStr(ret.Stream)}"); using (var fs = File.OpenWrite(@"d:\1.rar")) { ret.Stream.CopyTo(fs); } } catch (Exception e) { Console.WriteLine(e); throw; } }
private static async Task Test_SetStreamAsync() { Console.Write("[SetStreamAsync]...Send TestFile.txt"); using (var stream = File.Open(Helper.GetTestFilePath(), FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) await _proxyAsync.SetStreamAsync(stream); }
private static void Test_SetStream() { Console.Write("[SetStream]...Send TestFile.txt"); using (var stream = File.Open(Helper.GetTestFilePath(), FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) _proxy.SetStream(stream); }