Thrift doesn't support object/struct inheritence (see http://thrift.apache.org/docs/features/) So we have to manually define the resulting inherited structure here To build the code-gen .cs files run \packages\Thrift.0.9.0.0\tools\thrift-0.9.0.exe -gen csharp SimpleAndInheritedEntity.thrift You need to have NuGet restore the packages to have those tools because Thrift is a NuGet package in this project
Inheritance: Iface
Exemplo n.º 1
0
            public int Run()
            {
                int c = 0;

                try
                {
                    TTransport transport = new TSocket(Host, Port);
                    TProtocol  protocol  = new TBinaryProtocol(transport);
                    var        client    = new MultiplicationService.Client(protocol);

                    Console.WriteLine("Thrift client opening transport to {0} on port {1} ...", Host, Port);
                    transport.Open();


                    int a, b;
                    Console.Write("Enter 1st integer : ");
                    int.TryParse(Console.ReadLine(), out a);
                    Console.Write("Enter 2nd integer : ");
                    int.TryParse(Console.ReadLine(), out b);

                    c = client.multiply(a, b);

                    Console.WriteLine("{0} x {1} = {2}", a, b, c);
                    Console.WriteLine("Thrift client closing transport ...");
                    transport.Close();
                }
                catch (TApplicationException x)
                {
                    Console.WriteLine(x.StackTrace);
                }

                return(c);
            }
            public int Run()
            {
                int c = 0;

                try
                {
                    TTransport transport = new TSocket(Host, Port);
                    TProtocol protocol = new TBinaryProtocol(transport);
                    var client = new MultiplicationService.Client(protocol);

                    Console.WriteLine("Thrift client opening transport to {0} on port {1} ...", Host, Port);
                    transport.Open();

                    int a, b;
                    Console.Write("Enter 1st integer : ");
                    int.TryParse(Console.ReadLine(), out a);
                    Console.Write("Enter 2nd integer : ");
                    int.TryParse(Console.ReadLine(), out b);

                    c = client.multiply(a, b);

                    Console.WriteLine("{0} x {1} = {2}", a, b, c);
                    Console.WriteLine("Thrift client closing transport ...");
                    transport.Close();

                }
                catch (TApplicationException x)
                {
                    Console.WriteLine(x.StackTrace);

                }

                return c;
            }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            var transport = new TSocket("localhost", 9090);
            var protocol  = new TBinaryProtocol(transport);
            var client    = new MultiplicationService.Client(protocol);

            transport.Open();

            var mult = client.multiply(2, 4);

            Console.WriteLine("mult: {0}", mult);
        }