public override async Task <bool> DispatchToMethod(int methodId, RpcTypes.RpcType rpcType, string senderOfRPC, long sequenceNumber, byte[] buffer, int cursor)
        {
            switch (methodId)
            {
            case 0:
                // Entry point
                await this.EntryPoint();

                break;

            case 1:
                // OnNextAsync
            {
                // deserialize arguments

                // arg0: TwitterObservable.AnalyticsResultString
                var p_0_ValueLength = buffer.ReadBufferedInt(cursor);
                cursor += IntSize(p_0_ValueLength);
                var p_0_ValueBuffer = new byte[p_0_ValueLength];
                Buffer.BlockCopy(buffer, cursor, p_0_ValueBuffer, 0, p_0_ValueLength);
                cursor += p_0_ValueLength;
                var p_0 = Ambrosia.BinarySerializer.Deserialize <TwitterObservable.AnalyticsResultString>(p_0_ValueBuffer);

                // call the method
                byte[]    argExBytes = null;
                int       argExSize  = 0;
                Exception currEx     = null;
                int       arg1Size   = 0;
                byte[]    arg1Bytes  = null;

                try
                {
                    await this.instance.OnNextAsync(p_0);
                }
                catch (Exception ex)
                {
                    currEx = ex;
                }

                if (!rpcType.IsFireAndForget())
                {
                    // serialize result and send it back (there isn't one)
                    arg1Size = 0;
                    var wp = this.StartRPC_ReturnValue(senderOfRPC, sequenceNumber, currEx == null ? arg1Size : argExSize, currEx == null ? ReturnValueTypes.EmptyReturnValue : ReturnValueTypes.Exception);

                    this.ReleaseBufferAndSend();
                }
            }
            break;
            }

            return(true);
        }
Exemple #2
0
        public override async Task <bool> DispatchToMethod(int methodId, RpcTypes.RpcType rpcType, string senderOfRPC, long sequenceNumber, byte[] buffer, int cursor)
        {
            switch (methodId)
            {
            case 0:
                // Entry point
                this.EntryPoint();
                break;
            }

            return(true);
        }
        public override async Task <bool> DispatchToMethod(int methodId, RpcTypes.RpcType rpcType, string senderOfRPC, long sequenceNumber, byte[] buffer, int cursor)
        {
            switch (methodId)
            {
            case 0:
                // Entry point
                await EntryPoint();

                break;

            default:
                // should never get called since it was generated from a call to Create for an Empty API
                throw new NotImplementedException();
            }
            return(true);
        }
Exemple #4
0
        public override async Task <bool> DispatchToMethod(int methodId, RpcTypes.RpcType rpcType, string senderOfRPC, long sequenceNumber, byte[] buffer, int cursor)
        {
            // arg1: string, so read its length, then the string itself
            var arg1Length = buffer.ReadBufferedInt(cursor);

            cursor += StreamCommunicator.IntSize(arg1Length);
            var arg1Buffer = new byte[arg1Length];

            Buffer.BlockCopy(buffer, cursor, arg1Buffer, 0, arg1Length);
            cursor += arg1Length;
            var arg1 = Encoding.UTF8.GetString(arg1Buffer);

            // call the method
            Console.WriteLine(arg1);

            return(true);
        }
Exemple #5
0
        public override async Task <bool> DispatchToMethod(int methodId, RpcTypes.RpcType rpcType, string senderOfRPC, long sequenceNumber, byte[] buffer, int cursor)
        {
            switch (methodId)
            {
            case 0:
                // Entry point
                await this.EntryPoint();

                break;

            case 1:
                // PrintBytesReceivedAsync
            {
                // deserialize arguments
                // call the method
                byte[]    argExBytes = null;
                int       argExSize  = 0;
                Exception currEx     = null;
                int       arg0Size   = 0;
                byte[]    arg0Bytes  = null;

                try
                {
                    await this.instance.PrintBytesReceivedAsync();
                }
                catch (Exception ex)
                {
                    currEx = ex;
                }

                if (!rpcType.IsFireAndForget())
                {
                    // serialize result and send it back (there isn't one)
                    arg0Size = 0;
                    var wp = this.StartRPC_ReturnValue(senderOfRPC, sequenceNumber, currEx == null ? arg0Size : argExSize, currEx == null ? ReturnValueTypes.EmptyReturnValue : ReturnValueTypes.Exception);

                    this.ReleaseBufferAndSend();
                }
            }
            break;
            }

            return(true);
        }
Exemple #6
0
        public override async Task <bool> DispatchToMethod(int methodId, RpcTypes.RpcType rpcType, string senderOfRPC, long sequenceNumber, byte[] buffer, int cursor)
        {
            switch (methodId)
            {
            case 0:
                // Entry point
                await this.EntryPoint();

                break;

            case 1:
                // JobContinueAsync
            {
                // deserialize arguments

                // arg0: System.Int32
                var p_0_ValueLength = buffer.ReadBufferedInt(cursor);
                cursor += IntSize(p_0_ValueLength);
                var p_0_ValueBuffer = new byte[p_0_ValueLength];
                Buffer.BlockCopy(buffer, cursor, p_0_ValueBuffer, 0, p_0_ValueLength);
                cursor += p_0_ValueLength;
                var p_0 = Ambrosia.BinarySerializer.Deserialize <System.Int32>(p_0_ValueBuffer);


                // arg1: System.Int64
                var p_1_ValueLength = buffer.ReadBufferedInt(cursor);
                cursor += IntSize(p_1_ValueLength);
                var p_1_ValueBuffer = new byte[p_1_ValueLength];
                Buffer.BlockCopy(buffer, cursor, p_1_ValueBuffer, 0, p_1_ValueLength);
                cursor += p_1_ValueLength;
                var p_1 = Ambrosia.BinarySerializer.Deserialize <System.Int64>(p_1_ValueBuffer);


                // arg2: JobAPI.BoxedDateTime
                var p_2_ValueLength = buffer.ReadBufferedInt(cursor);
                cursor += IntSize(p_2_ValueLength);
                var p_2_ValueBuffer = new byte[p_2_ValueLength];
                Buffer.BlockCopy(buffer, cursor, p_2_ValueBuffer, 0, p_2_ValueLength);
                cursor += p_2_ValueLength;
                var p_2 = Ambrosia.BinarySerializer.Deserialize <JobAPI.BoxedDateTime>(p_2_ValueBuffer);

                // call the method
                byte[]    argExBytes = null;
                int       argExSize  = 0;
                Exception currEx     = null;
                int       arg3Size   = 0;
                byte[]    arg3Bytes  = null;

                try
                {
                    await this.instance.JobContinueAsync(p_0, p_1, p_2);
                }
                catch (Exception ex)
                {
                    currEx = ex;
                }

                if (!rpcType.IsFireAndForget())
                {
                    // serialize result and send it back (there isn't one)
                    arg3Size = 0;
                    var wp = this.StartRPC_ReturnValue(senderOfRPC, sequenceNumber, currEx == null ? arg3Size : argExSize, currEx == null ? ReturnValueTypes.EmptyReturnValue : ReturnValueTypes.Exception);

                    this.ReleaseBufferAndSend();
                }
            }
            break;

            case 2:
                // MAsync
            {
                // deserialize arguments

                // arg0: System.Byte[]
                var p_0_ValueLength = buffer.ReadBufferedInt(cursor);
                cursor += IntSize(p_0_ValueLength);
                var p_0_ValueBuffer = new byte[p_0_ValueLength];
                Buffer.BlockCopy(buffer, cursor, p_0_ValueBuffer, 0, p_0_ValueLength);
                cursor += p_0_ValueLength;
                var p_0 = p_0_ValueBuffer;

                // call the method
                byte[]    argExBytes = null;
                int       argExSize  = 0;
                Exception currEx     = null;
                int       arg1Size   = 0;
                byte[]    arg1Bytes  = null;

                try
                {
                    await this.instance.MAsync(p_0);
                }
                catch (Exception ex)
                {
                    currEx = ex;
                }

                if (!rpcType.IsFireAndForget())
                {
                    // serialize result and send it back (there isn't one)
                    arg1Size = 0;
                    var wp = this.StartRPC_ReturnValue(senderOfRPC, sequenceNumber, currEx == null ? arg1Size : argExSize, currEx == null ? ReturnValueTypes.EmptyReturnValue : ReturnValueTypes.Exception);

                    this.ReleaseBufferAndSend();
                }
            }
            break;

            case 3:
                // PrintBytesReceivedAsync
            {
                // deserialize arguments
                // call the method
                byte[]    argExBytes = null;
                int       argExSize  = 0;
                Exception currEx     = null;
                int       arg0Size   = 0;
                byte[]    arg0Bytes  = null;

                try
                {
                    await this.instance.PrintBytesReceivedAsync();
                }
                catch (Exception ex)
                {
                    currEx = ex;
                }

                if (!rpcType.IsFireAndForget())
                {
                    // serialize result and send it back (there isn't one)
                    arg0Size = 0;
                    var wp = this.StartRPC_ReturnValue(senderOfRPC, sequenceNumber, currEx == null ? arg0Size : argExSize, currEx == null ? ReturnValueTypes.EmptyReturnValue : ReturnValueTypes.Exception);

                    this.ReleaseBufferAndSend();
                }
            }
            break;
            }

            return(true);
        }
        public override async Task <bool> DispatchToMethod(int methodId, RpcTypes.RpcType rpcType, string senderOfRPC, long sequenceNumber, byte[] buffer, int cursor)
        {
            switch (methodId)
            {
            case 0:
                // Entry point
                await this.EntryPoint();

                break;

            case 1:
                // ReceiveMessageAsync
            {
                // deserialize arguments

                // arg0: System.String
                var p_0_ValueLength = buffer.ReadBufferedInt(cursor);
                cursor += IntSize(p_0_ValueLength);
                var p_0_ValueBuffer = new byte[p_0_ValueLength];
                Buffer.BlockCopy(buffer, cursor, p_0_ValueBuffer, 0, p_0_ValueLength);
                cursor += p_0_ValueLength;
                var p_0 = Ambrosia.BinarySerializer.Deserialize <System.String>(p_0_ValueBuffer);

                // call the method
                var       p_1        = default(Int32);
                byte[]    argExBytes = null;
                int       argExSize  = 0;
                Exception currEx     = null;
                int       arg1Size   = 0;
                byte[]    arg1Bytes  = null;

                try
                {
                    p_1 =
                        await this.instance.ReceiveMessageAsync(p_0);
                }
                catch (Exception ex)
                {
                    currEx = ex;
                }

                if (!rpcType.IsFireAndForget())
                {
                    // serialize result and send it back
                    if (currEx != null)
                    {
                        var argExObject = this.exceptionSerializer.Serialize(currEx);
                        argExBytes = Ambrosia.BinarySerializer.Serialize(argExObject);
                        argExSize  = IntSize(argExBytes.Length) + argExBytes.Length;
                    }
                    else
                    {
                        arg1Bytes = Ambrosia.BinarySerializer.Serialize <System.Int32>(p_1);
                        arg1Size  = IntSize(arg1Bytes.Length) + arg1Bytes.Length;
                    }
                    var wp = this.StartRPC_ReturnValue(senderOfRPC, sequenceNumber, currEx == null ? arg1Size : argExSize, currEx == null ? ReturnValueTypes.ReturnValue : ReturnValueTypes.Exception);


                    if (currEx != null)
                    {
                        wp.curLength += wp.PageBytes.WriteInt(wp.curLength, argExBytes.Length);
                        Buffer.BlockCopy(argExBytes, 0, wp.PageBytes, wp.curLength, argExBytes.Length);
                        wp.curLength += argExBytes.Length;
                    }
                    else
                    {
                        wp.curLength += wp.PageBytes.WriteInt(wp.curLength, arg1Bytes.Length);
                        Buffer.BlockCopy(arg1Bytes, 0, wp.PageBytes, wp.curLength, arg1Bytes.Length);
                        wp.curLength += arg1Bytes.Length;
                    }
                    this.ReleaseBufferAndSend();
                }
            }
            break;
            }

            return(true);
        }
Exemple #8
0
        public override async Task <bool> DispatchToMethod(int methodId, RpcTypes.RpcType rpcType, string senderOfRPC, long sequenceNumber, byte[] buffer, int cursor)
        {
            switch (methodId)
            {
            case 0:
                // Entry point
                await this.EntryPoint();

                break;

            case 1:
                // DetAddItemAsync
            {
                // deserialize arguments

                // arg0: CommInterfaceClasses.Item
                var p_0_ValueLength = buffer.ReadBufferedInt(cursor);
                cursor += IntSize(p_0_ValueLength);
                var p_0_ValueBuffer = new byte[p_0_ValueLength];
                Buffer.BlockCopy(buffer, cursor, p_0_ValueBuffer, 0, p_0_ValueLength);
                cursor += p_0_ValueLength;
                var p_0 = Ambrosia.BinarySerializer.Deserialize <CommInterfaceClasses.Item>(p_0_ValueBuffer);

                // call the method
                var       p_1        = default(Boolean);
                byte[]    argExBytes = null;
                int       argExSize  = 0;
                Exception currEx     = null;
                int       arg1Size   = 0;
                byte[]    arg1Bytes  = null;

                try
                {
                    p_1 =
                        await this.instance.DetAddItemAsync(p_0);
                }
                catch (Exception ex)
                {
                    currEx = ex;
                }

                if (!rpcType.IsFireAndForget())
                {
                    // serialize result and send it back
                    if (currEx != null)
                    {
                        var argExObject = this.exceptionSerializer.Serialize(currEx);
                        argExBytes = Ambrosia.BinarySerializer.Serialize(argExObject);
                        argExSize  = IntSize(argExBytes.Length) + argExBytes.Length;
                    }
                    else
                    {
                        arg1Bytes = Ambrosia.BinarySerializer.Serialize <System.Boolean>(p_1);
                        arg1Size  = IntSize(arg1Bytes.Length) + arg1Bytes.Length;
                    }
                    var wp = this.StartRPC_ReturnValue(senderOfRPC, sequenceNumber, currEx == null ? arg1Size : argExSize, currEx == null ? ReturnValueTypes.ReturnValue : ReturnValueTypes.Exception);


                    if (currEx != null)
                    {
                        wp.curLength += wp.PageBytes.WriteInt(wp.curLength, argExBytes.Length);
                        Buffer.BlockCopy(argExBytes, 0, wp.PageBytes, wp.curLength, argExBytes.Length);
                        wp.curLength += argExBytes.Length;
                    }
                    else
                    {
                        wp.curLength += wp.PageBytes.WriteInt(wp.curLength, arg1Bytes.Length);
                        Buffer.BlockCopy(arg1Bytes, 0, wp.PageBytes, wp.curLength, arg1Bytes.Length);
                        wp.curLength += arg1Bytes.Length;
                    }
                    this.ReleaseBufferAndSend();
                }
            }
            break;

            case 2:
                // DetUpdateItemAsync
            {
                // deserialize arguments

                // arg0: CommInterfaceClasses.Item
                var p_0_ValueLength = buffer.ReadBufferedInt(cursor);
                cursor += IntSize(p_0_ValueLength);
                var p_0_ValueBuffer = new byte[p_0_ValueLength];
                Buffer.BlockCopy(buffer, cursor, p_0_ValueBuffer, 0, p_0_ValueLength);
                cursor += p_0_ValueLength;
                var p_0 = Ambrosia.BinarySerializer.Deserialize <CommInterfaceClasses.Item>(p_0_ValueBuffer);

                // call the method
                var       p_1        = default(Boolean);
                byte[]    argExBytes = null;
                int       argExSize  = 0;
                Exception currEx     = null;
                int       arg1Size   = 0;
                byte[]    arg1Bytes  = null;

                try
                {
                    p_1 =
                        await this.instance.DetUpdateItemAsync(p_0);
                }
                catch (Exception ex)
                {
                    currEx = ex;
                }

                if (!rpcType.IsFireAndForget())
                {
                    // serialize result and send it back
                    if (currEx != null)
                    {
                        var argExObject = this.exceptionSerializer.Serialize(currEx);
                        argExBytes = Ambrosia.BinarySerializer.Serialize(argExObject);
                        argExSize  = IntSize(argExBytes.Length) + argExBytes.Length;
                    }
                    else
                    {
                        arg1Bytes = Ambrosia.BinarySerializer.Serialize <System.Boolean>(p_1);
                        arg1Size  = IntSize(arg1Bytes.Length) + arg1Bytes.Length;
                    }
                    var wp = this.StartRPC_ReturnValue(senderOfRPC, sequenceNumber, currEx == null ? arg1Size : argExSize, currEx == null ? ReturnValueTypes.ReturnValue : ReturnValueTypes.Exception);


                    if (currEx != null)
                    {
                        wp.curLength += wp.PageBytes.WriteInt(wp.curLength, argExBytes.Length);
                        Buffer.BlockCopy(argExBytes, 0, wp.PageBytes, wp.curLength, argExBytes.Length);
                        wp.curLength += argExBytes.Length;
                    }
                    else
                    {
                        wp.curLength += wp.PageBytes.WriteInt(wp.curLength, arg1Bytes.Length);
                        Buffer.BlockCopy(arg1Bytes, 0, wp.PageBytes, wp.curLength, arg1Bytes.Length);
                        wp.curLength += arg1Bytes.Length;
                    }
                    this.ReleaseBufferAndSend();
                }
            }
            break;

            case 3:
                // DetDeleteItemAsync
            {
                // deserialize arguments

                // arg0: System.String
                var p_0_ValueLength = buffer.ReadBufferedInt(cursor);
                cursor += IntSize(p_0_ValueLength);
                var p_0_ValueBuffer = new byte[p_0_ValueLength];
                Buffer.BlockCopy(buffer, cursor, p_0_ValueBuffer, 0, p_0_ValueLength);
                cursor += p_0_ValueLength;
                var p_0 = Ambrosia.BinarySerializer.Deserialize <System.String>(p_0_ValueBuffer);

                // call the method
                var       p_1        = default(Boolean);
                byte[]    argExBytes = null;
                int       argExSize  = 0;
                Exception currEx     = null;
                int       arg1Size   = 0;
                byte[]    arg1Bytes  = null;

                try
                {
                    p_1 =
                        await this.instance.DetDeleteItemAsync(p_0);
                }
                catch (Exception ex)
                {
                    currEx = ex;
                }

                if (!rpcType.IsFireAndForget())
                {
                    // serialize result and send it back
                    if (currEx != null)
                    {
                        var argExObject = this.exceptionSerializer.Serialize(currEx);
                        argExBytes = Ambrosia.BinarySerializer.Serialize(argExObject);
                        argExSize  = IntSize(argExBytes.Length) + argExBytes.Length;
                    }
                    else
                    {
                        arg1Bytes = Ambrosia.BinarySerializer.Serialize <System.Boolean>(p_1);
                        arg1Size  = IntSize(arg1Bytes.Length) + arg1Bytes.Length;
                    }
                    var wp = this.StartRPC_ReturnValue(senderOfRPC, sequenceNumber, currEx == null ? arg1Size : argExSize, currEx == null ? ReturnValueTypes.ReturnValue : ReturnValueTypes.Exception);


                    if (currEx != null)
                    {
                        wp.curLength += wp.PageBytes.WriteInt(wp.curLength, argExBytes.Length);
                        Buffer.BlockCopy(argExBytes, 0, wp.PageBytes, wp.curLength, argExBytes.Length);
                        wp.curLength += argExBytes.Length;
                    }
                    else
                    {
                        wp.curLength += wp.PageBytes.WriteInt(wp.curLength, arg1Bytes.Length);
                        Buffer.BlockCopy(arg1Bytes, 0, wp.PageBytes, wp.curLength, arg1Bytes.Length);
                        wp.curLength += arg1Bytes.Length;
                    }
                    this.ReleaseBufferAndSend();
                }
            }
            break;

            case 4:
                // ImpAddItemAsync
            {
                // deserialize arguments

                // arg0: CommInterfaceClasses.Item
                var p_0_ValueLength = buffer.ReadBufferedInt(cursor);
                cursor += IntSize(p_0_ValueLength);
                var p_0_ValueBuffer = new byte[p_0_ValueLength];
                Buffer.BlockCopy(buffer, cursor, p_0_ValueBuffer, 0, p_0_ValueLength);
                cursor += p_0_ValueLength;
                var p_0 = Ambrosia.BinarySerializer.Deserialize <CommInterfaceClasses.Item>(p_0_ValueBuffer);

                // call the method
                byte[]    argExBytes = null;
                int       argExSize  = 0;
                Exception currEx     = null;
                int       arg1Size   = 0;
                byte[]    arg1Bytes  = null;

                try
                {
                    await this.instance.ImpAddItemAsync(p_0);
                }
                catch (Exception ex)
                {
                    currEx = ex;
                }

                if (!rpcType.IsFireAndForget())
                {
                    // serialize result and send it back (there isn't one)
                    arg1Size = 0;
                    var wp = this.StartRPC_ReturnValue(senderOfRPC, sequenceNumber, currEx == null ? arg1Size : argExSize, currEx == null ? ReturnValueTypes.EmptyReturnValue : ReturnValueTypes.Exception);

                    this.ReleaseBufferAndSend();
                }
            }
            break;

            case 5:
                // ImpUpdateItemAsync
            {
                // deserialize arguments

                // arg0: CommInterfaceClasses.Item
                var p_0_ValueLength = buffer.ReadBufferedInt(cursor);
                cursor += IntSize(p_0_ValueLength);
                var p_0_ValueBuffer = new byte[p_0_ValueLength];
                Buffer.BlockCopy(buffer, cursor, p_0_ValueBuffer, 0, p_0_ValueLength);
                cursor += p_0_ValueLength;
                var p_0 = Ambrosia.BinarySerializer.Deserialize <CommInterfaceClasses.Item>(p_0_ValueBuffer);

                // call the method
                byte[]    argExBytes = null;
                int       argExSize  = 0;
                Exception currEx     = null;
                int       arg1Size   = 0;
                byte[]    arg1Bytes  = null;

                try
                {
                    await this.instance.ImpUpdateItemAsync(p_0);
                }
                catch (Exception ex)
                {
                    currEx = ex;
                }

                if (!rpcType.IsFireAndForget())
                {
                    // serialize result and send it back (there isn't one)
                    arg1Size = 0;
                    var wp = this.StartRPC_ReturnValue(senderOfRPC, sequenceNumber, currEx == null ? arg1Size : argExSize, currEx == null ? ReturnValueTypes.EmptyReturnValue : ReturnValueTypes.Exception);

                    this.ReleaseBufferAndSend();
                }
            }
            break;

            case 6:
                // ImpDeleteItemAsync
            {
                // deserialize arguments

                // arg0: System.String
                var p_0_ValueLength = buffer.ReadBufferedInt(cursor);
                cursor += IntSize(p_0_ValueLength);
                var p_0_ValueBuffer = new byte[p_0_ValueLength];
                Buffer.BlockCopy(buffer, cursor, p_0_ValueBuffer, 0, p_0_ValueLength);
                cursor += p_0_ValueLength;
                var p_0 = Ambrosia.BinarySerializer.Deserialize <System.String>(p_0_ValueBuffer);

                // call the method
                byte[]    argExBytes = null;
                int       argExSize  = 0;
                Exception currEx     = null;
                int       arg1Size   = 0;
                byte[]    arg1Bytes  = null;

                try
                {
                    await this.instance.ImpDeleteItemAsync(p_0);
                }
                catch (Exception ex)
                {
                    currEx = ex;
                }

                if (!rpcType.IsFireAndForget())
                {
                    // serialize result and send it back (there isn't one)
                    arg1Size = 0;
                    var wp = this.StartRPC_ReturnValue(senderOfRPC, sequenceNumber, currEx == null ? arg1Size : argExSize, currEx == null ? ReturnValueTypes.EmptyReturnValue : ReturnValueTypes.Exception);

                    this.ReleaseBufferAndSend();
                }
            }
            break;

            case 7:
                // GetItemAsync
            {
                // deserialize arguments

                // arg0: System.String
                var p_0_ValueLength = buffer.ReadBufferedInt(cursor);
                cursor += IntSize(p_0_ValueLength);
                var p_0_ValueBuffer = new byte[p_0_ValueLength];
                Buffer.BlockCopy(buffer, cursor, p_0_ValueBuffer, 0, p_0_ValueLength);
                cursor += p_0_ValueLength;
                var p_0 = Ambrosia.BinarySerializer.Deserialize <System.String>(p_0_ValueBuffer);

                // call the method
                var       p_1        = default(CommInterfaceClasses.Item);
                byte[]    argExBytes = null;
                int       argExSize  = 0;
                Exception currEx     = null;
                int       arg1Size   = 0;
                byte[]    arg1Bytes  = null;

                try
                {
                    p_1 =
                        await this.instance.GetItemAsync(p_0);
                }
                catch (Exception ex)
                {
                    currEx = ex;
                }

                if (!rpcType.IsFireAndForget())
                {
                    // serialize result and send it back
                    if (currEx != null)
                    {
                        var argExObject = this.exceptionSerializer.Serialize(currEx);
                        argExBytes = Ambrosia.BinarySerializer.Serialize(argExObject);
                        argExSize  = IntSize(argExBytes.Length) + argExBytes.Length;
                    }
                    else
                    {
                        arg1Bytes = Ambrosia.BinarySerializer.Serialize <CommInterfaceClasses.Item>(p_1);
                        arg1Size  = IntSize(arg1Bytes.Length) + arg1Bytes.Length;
                    }
                    var wp = this.StartRPC_ReturnValue(senderOfRPC, sequenceNumber, currEx == null ? arg1Size : argExSize, currEx == null ? ReturnValueTypes.ReturnValue : ReturnValueTypes.Exception);


                    if (currEx != null)
                    {
                        wp.curLength += wp.PageBytes.WriteInt(wp.curLength, argExBytes.Length);
                        Buffer.BlockCopy(argExBytes, 0, wp.PageBytes, wp.curLength, argExBytes.Length);
                        wp.curLength += argExBytes.Length;
                    }
                    else
                    {
                        wp.curLength += wp.PageBytes.WriteInt(wp.curLength, arg1Bytes.Length);
                        Buffer.BlockCopy(arg1Bytes, 0, wp.PageBytes, wp.curLength, arg1Bytes.Length);
                        wp.curLength += arg1Bytes.Length;
                    }
                    this.ReleaseBufferAndSend();
                }
            }
            break;

            case 8:
                // GetItemsAsync
            {
                // deserialize arguments

                // arg0: System.Boolean
                var p_0_ValueLength = buffer.ReadBufferedInt(cursor);
                cursor += IntSize(p_0_ValueLength);
                var p_0_ValueBuffer = new byte[p_0_ValueLength];
                Buffer.BlockCopy(buffer, cursor, p_0_ValueBuffer, 0, p_0_ValueLength);
                cursor += p_0_ValueLength;
                var p_0 = Ambrosia.BinarySerializer.Deserialize <System.Boolean>(p_0_ValueBuffer);

                // call the method
                var       p_1        = default(CommInterfaceClasses.Item[]);
                byte[]    argExBytes = null;
                int       argExSize  = 0;
                Exception currEx     = null;
                int       arg1Size   = 0;
                byte[]    arg1Bytes  = null;

                try
                {
                    p_1 =
                        await this.instance.GetItemsAsync(p_0);
                }
                catch (Exception ex)
                {
                    currEx = ex;
                }

                if (!rpcType.IsFireAndForget())
                {
                    // serialize result and send it back
                    if (currEx != null)
                    {
                        var argExObject = this.exceptionSerializer.Serialize(currEx);
                        argExBytes = Ambrosia.BinarySerializer.Serialize(argExObject);
                        argExSize  = IntSize(argExBytes.Length) + argExBytes.Length;
                    }
                    else
                    {
                        arg1Bytes = Ambrosia.BinarySerializer.Serialize <CommInterfaceClasses.Item[]>(p_1);
                        arg1Size  = IntSize(arg1Bytes.Length) + arg1Bytes.Length;
                    }
                    var wp = this.StartRPC_ReturnValue(senderOfRPC, sequenceNumber, currEx == null ? arg1Size : argExSize, currEx == null ? ReturnValueTypes.ReturnValue : ReturnValueTypes.Exception);


                    if (currEx != null)
                    {
                        wp.curLength += wp.PageBytes.WriteInt(wp.curLength, argExBytes.Length);
                        Buffer.BlockCopy(argExBytes, 0, wp.PageBytes, wp.curLength, argExBytes.Length);
                        wp.curLength += argExBytes.Length;
                    }
                    else
                    {
                        wp.curLength += wp.PageBytes.WriteInt(wp.curLength, arg1Bytes.Length);
                        Buffer.BlockCopy(arg1Bytes, 0, wp.PageBytes, wp.curLength, arg1Bytes.Length);
                        wp.curLength += arg1Bytes.Length;
                    }
                    this.ReleaseBufferAndSend();
                }
            }
            break;
            }

            return(true);
        }
Exemple #9
0
        public override async Task <bool> DispatchToMethod(int methodId, RpcTypes.RpcType rpcType, string senderOfRPC, long sequenceNumber, byte[] buffer, int cursor)
        {
            switch (methodId)
            {
            case 0:
                // Entry point
                await this.EntryPoint();

                break;

            case 1:
                // SubmitCommandAsync
            {
                // deserialize arguments

                // arg0: System.String
                var p_0_ValueLength = buffer.ReadBufferedInt(cursor);
                cursor += IntSize(p_0_ValueLength);
                var p_0_ValueBuffer = new byte[p_0_ValueLength];
                Buffer.BlockCopy(buffer, cursor, p_0_ValueBuffer, 0, p_0_ValueLength);
                cursor += p_0_ValueLength;
                var p_0 = Ambrosia.BinarySerializer.Deserialize <System.String>(p_0_ValueBuffer);

                // call the method
                byte[]    argExBytes = null;
                int       argExSize  = 0;
                Exception currEx     = null;
                int       arg1Size   = 0;
                byte[]    arg1Bytes  = null;

                try
                {
                    await this.instance.SubmitCommandAsync(p_0);
                }
                catch (Exception ex)
                {
                    currEx = ex;
                }

                if (!rpcType.IsFireAndForget())
                {
                    // serialize result and send it back (there isn't one)
                    arg1Size = 0;
                    var wp = this.StartRPC_ReturnValue(senderOfRPC, sequenceNumber, currEx == null ? arg1Size : argExSize, currEx == null ? ReturnValueTypes.EmptyReturnValue : ReturnValueTypes.Exception);

                    this.ReleaseBufferAndSend();
                }
            }
            break;

            case 2:
                // SetRootDirectoryAsync
            {
                // deserialize arguments

                // arg0: System.String
                var p_0_ValueLength = buffer.ReadBufferedInt(cursor);
                cursor += IntSize(p_0_ValueLength);
                var p_0_ValueBuffer = new byte[p_0_ValueLength];
                Buffer.BlockCopy(buffer, cursor, p_0_ValueBuffer, 0, p_0_ValueLength);
                cursor += p_0_ValueLength;
                var p_0 = Ambrosia.BinarySerializer.Deserialize <System.String>(p_0_ValueBuffer);

                // call the method
                byte[]    argExBytes = null;
                int       argExSize  = 0;
                Exception currEx     = null;
                int       arg1Size   = 0;
                byte[]    arg1Bytes  = null;

                try
                {
                    await this.instance.SetRootDirectoryAsync(p_0);
                }
                catch (Exception ex)
                {
                    currEx = ex;
                }

                if (!rpcType.IsFireAndForget())
                {
                    // serialize result and send it back (there isn't one)
                    arg1Size = 0;
                    var wp = this.StartRPC_ReturnValue(senderOfRPC, sequenceNumber, currEx == null ? arg1Size : argExSize, currEx == null ? ReturnValueTypes.EmptyReturnValue : ReturnValueTypes.Exception);

                    this.ReleaseBufferAndSend();
                }
            }
            break;

            case 3:
                // SetRelativeDirectoryAsync
            {
                // deserialize arguments

                // arg0: System.String
                var p_0_ValueLength = buffer.ReadBufferedInt(cursor);
                cursor += IntSize(p_0_ValueLength);
                var p_0_ValueBuffer = new byte[p_0_ValueLength];
                Buffer.BlockCopy(buffer, cursor, p_0_ValueBuffer, 0, p_0_ValueLength);
                cursor += p_0_ValueLength;
                var p_0 = Ambrosia.BinarySerializer.Deserialize <System.String>(p_0_ValueBuffer);

                // call the method
                byte[]    argExBytes = null;
                int       argExSize  = 0;
                Exception currEx     = null;
                int       arg1Size   = 0;
                byte[]    arg1Bytes  = null;

                try
                {
                    await this.instance.SetRelativeDirectoryAsync(p_0);
                }
                catch (Exception ex)
                {
                    currEx = ex;
                }

                if (!rpcType.IsFireAndForget())
                {
                    // serialize result and send it back (there isn't one)
                    arg1Size = 0;
                    var wp = this.StartRPC_ReturnValue(senderOfRPC, sequenceNumber, currEx == null ? arg1Size : argExSize, currEx == null ? ReturnValueTypes.EmptyReturnValue : ReturnValueTypes.Exception);

                    this.ReleaseBufferAndSend();
                }
            }
            break;

            case 4:
                // AddConsoleOutputAsync
            {
                // deserialize arguments

                // arg0: System.String
                var p_0_ValueLength = buffer.ReadBufferedInt(cursor);
                cursor += IntSize(p_0_ValueLength);
                var p_0_ValueBuffer = new byte[p_0_ValueLength];
                Buffer.BlockCopy(buffer, cursor, p_0_ValueBuffer, 0, p_0_ValueLength);
                cursor += p_0_ValueLength;
                var p_0 = Ambrosia.BinarySerializer.Deserialize <System.String>(p_0_ValueBuffer);

                // call the method
                byte[]    argExBytes = null;
                int       argExSize  = 0;
                Exception currEx     = null;
                int       arg1Size   = 0;
                byte[]    arg1Bytes  = null;

                try
                {
                    await this.instance.AddConsoleOutputAsync(p_0);
                }
                catch (Exception ex)
                {
                    currEx = ex;
                }

                if (!rpcType.IsFireAndForget())
                {
                    // serialize result and send it back (there isn't one)
                    arg1Size = 0;
                    var wp = this.StartRPC_ReturnValue(senderOfRPC, sequenceNumber, currEx == null ? arg1Size : argExSize, currEx == null ? ReturnValueTypes.EmptyReturnValue : ReturnValueTypes.Exception);

                    this.ReleaseBufferAndSend();
                }
            }
            break;

            case 5:
                // IncCurrentCommandAsync
            {
                // deserialize arguments
                // call the method
                byte[]    argExBytes = null;
                int       argExSize  = 0;
                Exception currEx     = null;
                int       arg0Size   = 0;
                byte[]    arg0Bytes  = null;

                try
                {
                    await this.instance.IncCurrentCommandAsync();
                }
                catch (Exception ex)
                {
                    currEx = ex;
                }

                if (!rpcType.IsFireAndForget())
                {
                    // serialize result and send it back (there isn't one)
                    arg0Size = 0;
                    var wp = this.StartRPC_ReturnValue(senderOfRPC, sequenceNumber, currEx == null ? arg0Size : argExSize, currEx == null ? ReturnValueTypes.EmptyReturnValue : ReturnValueTypes.Exception);

                    this.ReleaseBufferAndSend();
                }
            }
            break;

            case 6:
                // DecCurrentCommandAsync
            {
                // deserialize arguments
                // call the method
                byte[]    argExBytes = null;
                int       argExSize  = 0;
                Exception currEx     = null;
                int       arg0Size   = 0;
                byte[]    arg0Bytes  = null;

                try
                {
                    await this.instance.DecCurrentCommandAsync();
                }
                catch (Exception ex)
                {
                    currEx = ex;
                }

                if (!rpcType.IsFireAndForget())
                {
                    // serialize result and send it back (there isn't one)
                    arg0Size = 0;
                    var wp = this.StartRPC_ReturnValue(senderOfRPC, sequenceNumber, currEx == null ? arg0Size : argExSize, currEx == null ? ReturnValueTypes.EmptyReturnValue : ReturnValueTypes.Exception);

                    this.ReleaseBufferAndSend();
                }
            }
            break;
            }

            return(true);
        }