Beispiel #1
0
        public override bool TryInvoke(InvokeBinder binder, object[] args, out object result)
        {
            result = null;
            //if (Connector.ServerIsClosed) return false;

            if (args.Length == 1 && ReferenceEquals(args[0], FlagDeleteObject))
            {
                Dispose(true);
                return(true);
            }

            var ms = new MemoryStream();
            var bw = new BinaryWriter(ms);

            bw.Write((byte)CallMethod.CallDelegate);
            bw.Write(Target);

            bw.Write(args.Length);
            foreach (var arg in args)
            {
                WorkVariants.WriteObject(arg, bw);
            }

            bw.Flush();

            var res = Connector.SendMessage(ms);

            return(GetResult(res, ref result, Connector));
        }
Beispiel #2
0
        internal static bool TryInvokeGenericMethod(int target, string methodName, object[] args, out object result, TcpConnector 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));
        }
Beispiel #3
0
        public override bool TrySetMember(SetMemberBinder binder, object value)
        {
            //if (Connector.ServerIsClosed) return false;

            var ms = new MemoryStream();
            var bw = new BinaryWriter(ms);

            bw.Write((byte)CallMethod.SetMember);
            bw.Write(Target);
            bw.Write(binder.Name);
            WorkVariants.WriteObject(value, bw);

            var    res    = Connector.SendMessage(ms);
            object result = null;

            return(GetResult(res, ref result, Connector));
        }
Beispiel #4
0
        public override bool TryBinaryOperation(
            BinaryOperationBinder binder, object arg, out object result)
        {
            result = null;

            var ms = new MemoryStream();
            var bw = new BinaryWriter(ms);

            bw.Write((byte)CallMethod.CallBinaryOperation);
            bw.Write(Target);
            bw.Write((byte)binder.Operation);
            WorkVariants.WriteObject(arg, bw);

            bw.Flush();
            var res = Connector.SendMessage(ms);

            return(GetResult(res, ref result, Connector));
        }
Beispiel #5
0
        internal static bool TryInvokeMember(int target, string methodName, object[] args, out object result,
                                             TcpConnector 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));
        }
Beispiel #6
0
        public override bool TryGetIndex(
            GetIndexBinder binder, object[] indexes, out object result)
        {
            result = null;
            //if (Connector.ServerIsClosed) return false;

            var ms = new MemoryStream();
            var bw = new BinaryWriter(ms);

            bw.Write((byte)CallMethod.GetIndex);
            bw.Write(Target);
            bw.Write(indexes.Length);
            foreach (var arg in indexes)
            {
                WorkVariants.WriteObject(arg, bw);
            }

            bw.Flush();

            var res = Connector.SendMessage(ms);

            return(GetResult(res, ref result, Connector));
        }