/**
 * Autogenerated by Thrift Compiler (0.9.3)
 *
 * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
 *  @generated
 */
using System.Text;
using Thrift;
using Thrift.Protocol;

public partial class WcsThrift
{
    public interface Iface
    {
        string hello(string name);
#if SILVERLIGHT
    IAsyncResult Begin_hello(AsyncCallback callback, object state, string name);
    string End_hello(IAsyncResult asyncResult);
#endif
        string SendCar(List<string> carlist, string order_code, string amount);
#if SILVERLIGHT
    IAsyncResult Begin_SendCar(AsyncCallback callback, object state, List<string> carlist, string order_code, string amount);
    string End_SendCar(IAsyncResult asyncResult);
#endif
    }

    public class Client : IDisposable, Iface
    {
        public Client(TProtocol prot) : this(prot, prot)
        {
        }

        public Client(TProtocol iprot, TProtocol oprot)
        {
            iprot_ = iprot;
            oprot_ = oprot;
        }

        protected TProtocol iprot_;
        protected TProtocol oprot_;
        protected int seqid_;

        public TProtocol InputProtocol
        {
            get { return iprot_; }
        }
        public TProtocol OutputProtocol
        {
            get { return oprot_; }
        }


        #region " IDisposable Support "
        private bool _IsDisposed;

        // IDisposable
        public void Dispose()
        {
            Dispose(true);
        }


        protected virtual void Dispose(bool disposing)
        {
            if (!_IsDisposed)
            {
                if (disposing)
                {
                    if (iprot_ != null)
                    {
                        ((IDisposable)iprot_).Dispose();
                    }
                    if (oprot_ != null)
                    {
                        ((IDisposable)oprot_).Dispose();
                    }
                }
            }
            _IsDisposed = true;
        }
        #endregion



#if SILVERLIGHT
    public IAsyncResult Begin_hello(AsyncCallback callback, object state, string name)
    {
      return send_hello(callback, state, name);
    }

    public string End_hello(IAsyncResult asyncResult)
    {
      oprot_.Transport.EndFlush(asyncResult);
      return recv_hello();
    }

#endif

        public string hello(string name)
        {
#if !SILVERLIGHT
            send_hello(name);
            return recv_hello();

#else
      var asyncResult = Begin_hello(null, null, name);
      return End_hello(asyncResult);

#endif
        }
#if SILVERLIGHT
    public IAsyncResult send_hello(AsyncCallback callback, object state, string name)
#else
        public void send_hello(string name)
#endif
        {
            oprot_.WriteMessageBegin(new TMessage("hello", TMessageType.Call, seqid_));
            hello_args args = new hello_args();
            args.Name = name;
            args.Write(oprot_);
            oprot_.WriteMessageEnd();
#if SILVERLIGHT
      return oprot_.Transport.BeginFlush(callback, state);
#else
            oprot_.Transport.Flush();
#endif
        }

        public string recv_hello()
        {
            TMessage msg = iprot_.ReadMessageBegin();
            if (msg.Type == TMessageType.Exception)
            {
                TApplicationException x = TApplicationException.Read(iprot_);
                iprot_.ReadMessageEnd();
                throw x;
            }
            hello_result result = new hello_result();
            result.Read(iprot_);
            iprot_.ReadMessageEnd();
            if (result.__isset.success)
            {
                return result.Success;
            }
            throw new TApplicationException(TApplicationException.ExceptionType.MissingResult, "hello failed: unknown result");
        }


#if SILVERLIGHT
    public IAsyncResult Begin_SendCar(AsyncCallback callback, object state, List<string> carlist, string order_code, string amount)
    {
      return send_SendCar(callback, state, carlist, order_code, amount);
    }

    public string End_SendCar(IAsyncResult asyncResult)
    {
      oprot_.Transport.EndFlush(asyncResult);
      return recv_SendCar();
    }

#endif

        public string SendCar(List<string> carlist, string order_code, string amount)
        {
#if !SILVERLIGHT
            send_SendCar(carlist, order_code, amount);
            return recv_SendCar();

#else
      var asyncResult = Begin_SendCar(null, null, carlist, order_code, amount);
      return End_SendCar(asyncResult);

#endif
        }
#if SILVERLIGHT
    public IAsyncResult send_SendCar(AsyncCallback callback, object state, List<string> carlist, string order_code, string amount)
#else
        public void send_SendCar(List<string> carlist, string order_code, string amount)
#endif
        {
            oprot_.WriteMessageBegin(new TMessage("SendCar", TMessageType.Call, seqid_));
            SendCar_args args = new SendCar_args();
            args.Carlist = carlist;
            args.Order_code = order_code;
            args.Amount = amount;
            args.Write(oprot_);
            oprot_.WriteMessageEnd();
#if SILVERLIGHT
      return oprot_.Transport.BeginFlush(callback, state);
#else
            oprot_.Transport.Flush();
#endif
        }

        public string recv_SendCar()
        {
            TMessage msg = iprot_.ReadMessageBegin();
            if (msg.Type == TMessageType.Exception)
            {
                TApplicationException x = TApplicationException.Read(iprot_);
                iprot_.ReadMessageEnd();
                throw x;
            }
            SendCar_result result = new SendCar_result();
            result.Read(iprot_);
            iprot_.ReadMessageEnd();
            if (result.__isset.success)
            {
                return result.Success;
            }
            throw new TApplicationException(TApplicationException.ExceptionType.MissingResult, "SendCar failed: unknown result");
        }

    }
    public class Processor : TProcessor
    {
        public Processor(Iface iface)
        {
            iface_ = iface;
            processMap_["hello"] = hello_Process;
            processMap_["SendCar"] = SendCar_Process;
        }

        protected delegate void ProcessFunction(int seqid, TProtocol iprot, TProtocol oprot);
        private Iface iface_;
        protected Dictionary<string, ProcessFunction> processMap_ = new Dictionary<string, ProcessFunction>();

        public bool Process(TProtocol iprot, TProtocol oprot)
        {
            try
            {
                TMessage msg = iprot.ReadMessageBegin();
                ProcessFunction fn;
                processMap_.TryGetValue(msg.Name, out fn);
                if (fn == null)
                {
                    TProtocolUtil.Skip(iprot, TType.Struct);
                    iprot.ReadMessageEnd();
                    TApplicationException x = new TApplicationException(TApplicationException.ExceptionType.UnknownMethod, "Invalid method name: '" + msg.Name + "'");
                    oprot.WriteMessageBegin(new TMessage(msg.Name, TMessageType.Exception, msg.SeqID));
                    x.Write(oprot);
                    oprot.WriteMessageEnd();
                    oprot.Transport.Flush();
                    return true;
                }
                fn(msg.SeqID, iprot, oprot);
            }
            catch (IOException)
            {
                return false;
            }
            return true;
        }

        public void hello_Process(int seqid, TProtocol iprot, TProtocol oprot)
        {
            hello_args args = new hello_args();
            args.Read(iprot);
            iprot.ReadMessageEnd();
            hello_result result = new hello_result();
            result.Success = iface_.hello(args.Name);
            oprot.WriteMessageBegin(new TMessage("hello", TMessageType.Reply, seqid));
            result.Write(oprot);
            oprot.WriteMessageEnd();
            oprot.Transport.Flush();
        }

        public void SendCar_Process(int seqid, TProtocol iprot, TProtocol oprot)
        {
            SendCar_args args = new SendCar_args();
            args.Read(iprot);
            iprot.ReadMessageEnd();
            SendCar_result result = new SendCar_result();
            result.Success = iface_.SendCar(args.Carlist, args.Order_code, args.Amount);
            oprot.WriteMessageBegin(new TMessage("SendCar", TMessageType.Reply, seqid));
            result.Write(oprot);
            oprot.WriteMessageEnd();
            oprot.Transport.Flush();
        }

    }


#if !SILVERLIGHT
    [Serializable]
#endif
    public partial class hello_args : TBase
    {
        private string _name;

        public string Name
        {
            get
            {
                return _name;
            }
            set
            {
                __isset.name = true;
                this._name = value;
            }
        }


        public Isset __isset;
#if !SILVERLIGHT
        [Serializable]
#endif
        public struct Isset
        {
            public bool name;
        }

        public hello_args()
        {
        }

        public void Read(TProtocol iprot)
        {
            iprot.IncrementRecursionDepth();
            try
            {
                TField field;
                iprot.ReadStructBegin();
                while (true)
                {
                    field = iprot.ReadFieldBegin();
                    if (field.Type == TType.Stop)
                    {
                        break;
                    }
                    switch (field.ID)
                    {
                        case 1:
                            if (field.Type == TType.String)
                            {
                                Name = iprot.ReadString();
                            }
                            else
                            {
                                TProtocolUtil.Skip(iprot, field.Type);
                            }
                            break;
                        default:
                            TProtocolUtil.Skip(iprot, field.Type);
                            break;
                    }
                    iprot.ReadFieldEnd();
                }
                iprot.ReadStructEnd();
            }
            finally
            {
                iprot.DecrementRecursionDepth();
            }
        }

        public void Write(TProtocol oprot)
        {
            oprot.IncrementRecursionDepth();
            try
            {
                TStruct struc = new TStruct("hello_args");
                oprot.WriteStructBegin(struc);
                TField field = new TField();
                if (Name != null && __isset.name)
                {
                    field.Name = "name";
                    field.Type = TType.String;
                    field.ID = 1;
                    oprot.WriteFieldBegin(field);
                    oprot.WriteString(Name);
                    oprot.WriteFieldEnd();
                }
                oprot.WriteFieldStop();
                oprot.WriteStructEnd();
            }
            finally
            {
                oprot.DecrementRecursionDepth();
            }
        }

        public override string ToString()
        {
            StringBuilder __sb = new StringBuilder("hello_args(");
            bool __first = true;
            if (Name != null && __isset.name)
            {
                if (!__first) { __sb.Append(", "); }
                __first = false;
                __sb.Append("Name: ");
                __sb.Append(Name);
            }
            __sb.Append(")");
            return __sb.ToString();
        }

    }


#if !SILVERLIGHT
    [Serializable]
#endif
    public partial class hello_result : TBase
    {
        private string _success;

        public string Success
        {
            get
            {
                return _success;
            }
            set
            {
                __isset.success = true;
                this._success = value;
            }
        }


        public Isset __isset;
#if !SILVERLIGHT
        [Serializable]
#endif
        public struct Isset
        {
            public bool success;
        }

        public hello_result()
        {
        }

        public void Read(TProtocol iprot)
        {
            iprot.IncrementRecursionDepth();
            try
            {
                TField field;
                iprot.ReadStructBegin();
                while (true)
                {
                    field = iprot.ReadFieldBegin();
                    if (field.Type == TType.Stop)
                    {
                        break;
                    }
                    switch (field.ID)
                    {
                        case 0:
                            if (field.Type == TType.String)
                            {
                                Success = iprot.ReadString();
                            }
                            else
                            {
                                TProtocolUtil.Skip(iprot, field.Type);
                            }
                            break;
                        default:
                            TProtocolUtil.Skip(iprot, field.Type);
                            break;
                    }
                    iprot.ReadFieldEnd();
                }
                iprot.ReadStructEnd();
            }
            finally
            {
                iprot.DecrementRecursionDepth();
            }
        }

        public void Write(TProtocol oprot)
        {
            oprot.IncrementRecursionDepth();
            try
            {
                TStruct struc = new TStruct("hello_result");
                oprot.WriteStructBegin(struc);
                TField field = new TField();

                if (this.__isset.success)
                {
                    if (Success != null)
                    {
                        field.Name = "Success";
                        field.Type = TType.String;
                        field.ID = 0;
                        oprot.WriteFieldBegin(field);
                        oprot.WriteString(Success);
                        oprot.WriteFieldEnd();
                    }
                }
                oprot.WriteFieldStop();
                oprot.WriteStructEnd();
            }
            finally
            {
                oprot.DecrementRecursionDepth();
            }
        }

        public override string ToString()
        {
            StringBuilder __sb = new StringBuilder("hello_result(");
            bool __first = true;
            if (Success != null && __isset.success)
            {
                if (!__first) { __sb.Append(", "); }
                __first = false;
                __sb.Append("Success: ");
                __sb.Append(Success);
            }
            __sb.Append(")");
            return __sb.ToString();
        }

    }


#if !SILVERLIGHT
    [Serializable]
#endif
    public partial class SendCar_args : TBase
    {
        private List<string> _carlist;
        private string _order_code;
        private string _amount;

        public List<string> Carlist
        {
            get
            {
                return _carlist;
            }
            set
            {
                __isset.carlist = true;
                this._carlist = value;
            }
        }

        public string Order_code
        {
            get
            {
                return _order_code;
            }
            set
            {
                __isset.order_code = true;
                this._order_code = value;
            }
        }

        public string Amount
        {
            get
            {
                return _amount;
            }
            set
            {
                __isset.amount = true;
                this._amount = value;
            }
        }


        public Isset __isset;
#if !SILVERLIGHT
        [Serializable]
#endif
        public struct Isset
        {
            public bool carlist;
            public bool order_code;
            public bool amount;
        }

        public SendCar_args()
        {
        }

        public void Read(TProtocol iprot)
        {
            iprot.IncrementRecursionDepth();
            try
            {
                TField field;
                iprot.ReadStructBegin();
                while (true)
                {
                    field = iprot.ReadFieldBegin();
                    if (field.Type == TType.Stop)
                    {
                        break;
                    }
                    switch (field.ID)
                    {
                        case 1:
                            if (field.Type == TType.List)
                            {
                                {
                                    Carlist = new List<string>();
                                    TList _list0 = iprot.ReadListBegin();
                                    for (int _i1 = 0; _i1 < _list0.Count; ++_i1)
                                    {
                                        string _elem2;
                                        _elem2 = iprot.ReadString();
                                        Carlist.Add(_elem2);
                                    }
                                    iprot.ReadListEnd();
                                }
                            }
                            else
                            {
                                TProtocolUtil.Skip(iprot, field.Type);
                            }
                            break;
                        case 2:
                            if (field.Type == TType.String)
                            {
                                Order_code = iprot.ReadString();
                            }
                            else
                            {
                                TProtocolUtil.Skip(iprot, field.Type);
                            }
                            break;
                        case 3:
                            if (field.Type == TType.String)
                            {
                                Amount = iprot.ReadString();
                            }
                            else
                            {
                                TProtocolUtil.Skip(iprot, field.Type);
                            }
                            break;
                        default:
                            TProtocolUtil.Skip(iprot, field.Type);
                            break;
                    }
                    iprot.ReadFieldEnd();
                }
                iprot.ReadStructEnd();
            }
            finally
            {
                iprot.DecrementRecursionDepth();
            }
        }

        public void Write(TProtocol oprot)
        {
            oprot.IncrementRecursionDepth();
            try
            {
                TStruct struc = new TStruct("SendCar_args");
                oprot.WriteStructBegin(struc);
                TField field = new TField();
                if (Carlist != null && __isset.carlist)
                {
                    field.Name = "carlist";
                    field.Type = TType.List;
                    field.ID = 1;
                    oprot.WriteFieldBegin(field);
                    {
                        oprot.WriteListBegin(new TList(TType.String, Carlist.Count));
                        foreach (string _iter3 in Carlist)
                        {
                            oprot.WriteString(_iter3);
                        }
                        oprot.WriteListEnd();
                    }
                    oprot.WriteFieldEnd();
                }
                if (Order_code != null && __isset.order_code)
                {
                    field.Name = "order_code";
                    field.Type = TType.String;
                    field.ID = 2;
                    oprot.WriteFieldBegin(field);
                    oprot.WriteString(Order_code);
                    oprot.WriteFieldEnd();
                }
                if (Amount != null && __isset.amount)
                {
                    field.Name = "amount";
                    field.Type = TType.String;
                    field.ID = 3;
                    oprot.WriteFieldBegin(field);
                    oprot.WriteString(Amount);
                    oprot.WriteFieldEnd();
                }
                oprot.WriteFieldStop();
                oprot.WriteStructEnd();
            }
            finally
            {
                oprot.DecrementRecursionDepth();
            }
        }

        public override string ToString()
        {
            StringBuilder __sb = new StringBuilder("SendCar_args(");
            bool __first = true;
            if (Carlist != null && __isset.carlist)
            {
                if (!__first) { __sb.Append(", "); }
                __first = false;
                __sb.Append("Carlist: ");
                __sb.Append(Carlist);
            }
            if (Order_code != null && __isset.order_code)
            {
                if (!__first) { __sb.Append(", "); }
                __first = false;
                __sb.Append("Order_code: ");
                __sb.Append(Order_code);
            }
            if (Amount != null && __isset.amount)
            {
                if (!__first) { __sb.Append(", "); }
                __first = false;
                __sb.Append("Amount: ");
                __sb.Append(Amount);
            }
            __sb.Append(")");
            return __sb.ToString();
        }

    }


#if !SILVERLIGHT
    [Serializable]
#endif
    public partial class SendCar_result : TBase
    {
        private string _success;

        public string Success
        {
            get
            {
                return _success;
            }
            set
            {
                __isset.success = true;
                this._success = value;
            }
        }


        public Isset __isset;
#if !SILVERLIGHT
        [Serializable]
#endif
        public struct Isset
        {
            public bool success;
        }

        public SendCar_result()
        {
        }

        public void Read(TProtocol iprot)
        {
            iprot.IncrementRecursionDepth();
            try
            {
                TField field;
                iprot.ReadStructBegin();
                while (true)
                {
                    field = iprot.ReadFieldBegin();
                    if (field.Type == TType.Stop)
                    {
                        break;
                    }
                    switch (field.ID)
                    {
                        case 0:
                            if (field.Type == TType.String)
                            {
                                Success = iprot.ReadString();
                            }
                            else
                            {
                                TProtocolUtil.Skip(iprot, field.Type);
                            }
                            break;
                        default:
                            TProtocolUtil.Skip(iprot, field.Type);
                            break;
                    }
                    iprot.ReadFieldEnd();
                }
                iprot.ReadStructEnd();
            }
            finally
            {
                iprot.DecrementRecursionDepth();
            }
        }

        public void Write(TProtocol oprot)
        {
            oprot.IncrementRecursionDepth();
            try
            {
                TStruct struc = new TStruct("SendCar_result");
                oprot.WriteStructBegin(struc);
                TField field = new TField();

                if (this.__isset.success)
                {
                    if (Success != null)
                    {
                        field.Name = "Success";
                        field.Type = TType.String;
                        field.ID = 0;
                        oprot.WriteFieldBegin(field);
                        oprot.WriteString(Success);
                        oprot.WriteFieldEnd();
                    }
                }
                oprot.WriteFieldStop();
                oprot.WriteStructEnd();
            }
            finally
            {
                oprot.DecrementRecursionDepth();
            }
        }

        public override string ToString()
        {
            StringBuilder __sb = new StringBuilder("SendCar_result(");
            bool __first = true;
            if (Success != null && __isset.success)
            {
                if (!__first) { __sb.Append(", "); }
                __first = false;
                __sb.Append("Success: ");
                __sb.Append(Success);
            }
            __sb.Append(")");
            return __sb.ToString();
        }

    }

}
