internal static bool TryInvokeGenericMethod(int target, string methodName, object[] args, out object result, TCPClientConnector connector) { var ms = new MemoryStream(); var bw = new BinaryWriter(ms); bw.Write((byte)CallMethod.CallGenericFunc); bw.Write(target); bw.Write(methodName); var arguments = (object[])args[0]; bw.Write(arguments.Length); foreach (var arg in arguments) { WorkVariants.WriteObject(arg, bw); } bw.Write(args.Length - 1); for (var i = 1; i < args.Length; i++) { WorkVariants.WriteObject(args[i], bw); } bw.Flush(); var res = connector.SendMessage(ms); result = null; return(GetResultWithChangeParams(res, ref result, connector, args, 1)); }
public bool MoveNext() { var ms = new MemoryStream(); var bw = new BinaryWriter(ms); bw.Write((byte)CallMethod.IteratorNext); bw.Write(_enumerator.Target); bw.Flush(); var res = _connector.SendMessage(ms); var resCall = res.ReadBoolean(); if (!resCall) { throw new Exception(res.ReadString()); } var resNext = res.ReadBoolean(); if (!resNext) { GC.SuppressFinalize(_enumerator); return(false); } Current = WorkVariants.GetObject(res, _connector); return(true); }
internal static bool TryInvokeMember(int target, string methodName, object[] args, out object result, TCPClientConnector connector) { result = null; var ms = new MemoryStream(); var bw = new BinaryWriter(ms); bw.Write((byte)CallMethod.CallFunc); bw.Write(target); bw.Write(methodName); bw.Write(args.Length); foreach (var arg in args) { WorkVariants.WriteObject(arg, bw); } bw.Flush(); return(GetResultWithChangeParams(connector.SendMessage(ms), ref result, connector, args)); }