Ejemplo n.º 1
0
     public double Compute(EnumOP op, OPNum num)
     {
 #if !SILVERLIGHT
         send_Compute(op, num);
         return(recv_Compute());
 #else
         var asyncResult = Begin_Compute(null, null, op, num);
         return(End_Compute(asyncResult));
 #endif
     }
Ejemplo n.º 2
0
            public void send_Compute(EnumOP op, OPNum num)
      #endif
            {
                oprot_.WriteMessageBegin(new TMessage("Compute", TMessageType.Call, seqid_));
                Compute_args args = new Compute_args();

                args.Op  = op;
                args.Num = num;
                args.Write(oprot_);
                oprot_.WriteMessageEnd();
        #if SILVERLIGHT
                return(oprot_.Transport.BeginFlush(callback, state));
        #else
                oprot_.Transport.Flush();
        #endif
            }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            TTransport transport = new TSocket("localhost", 8088);  // 设置调用地址为本地,端口为8088

            transport.Open();
            TProtocol protocol = new TBinaryProtocol(transport);    // 设置传输协议为 TBinaryProtocol

            MathService.Client client = new MathService.Client(protocol);
            //Console.WriteLine(client.add(1, 2));    //调用服务的 add() 方法
            OPNum opNum = new OPNum();

            opNum.Num1 = 10;
            opNum.Num2 = 20;
            Console.WriteLine(client.Compute(EnumOP.Div, opNum));
            transport.Close();
            Console.ReadKey();
        }
Ejemplo n.º 4
0
            public void Read(TProtocol iprot)
            {
                TField field;

                iprot.ReadStructBegin();
                while (true)
                {
                    field = iprot.ReadFieldBegin();
                    if (field.Type == TType.Stop)
                    {
                        break;
                    }
                    switch (field.ID)
                    {
                    case 1:
                        if (field.Type == TType.I32)
                        {
                            Op = (EnumOP)iprot.ReadI32();
                        }
                        else
                        {
                            TProtocolUtil.Skip(iprot, field.Type);
                        }
                        break;

                    case 2:
                        if (field.Type == TType.Struct)
                        {
                            Num = new OPNum();
                            Num.Read(iprot);
                        }
                        else
                        {
                            TProtocolUtil.Skip(iprot, field.Type);
                        }
                        break;

                    default:
                        TProtocolUtil.Skip(iprot, field.Type);
                        break;
                    }
                    iprot.ReadFieldEnd();
                }
                iprot.ReadStructEnd();
            }
Ejemplo n.º 5
0
 public IAsyncResult send_Compute(AsyncCallback callback, object state, EnumOP op, OPNum num)
Ejemplo n.º 6
0
 public IAsyncResult Begin_Compute(AsyncCallback callback, object state, EnumOP op, OPNum num)
 {
     return(send_Compute(callback, state, op, num));
 }