You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by dr...@apache.org on 2009/03/30 23:22:53 UTC

svn commit: r760181 - in /incubator/thrift/trunk/test/csharp: CSharpClient.cs CSharpServer.cs

Author: dreiss
Date: Mon Mar 30 21:22:52 2009
New Revision: 760181

URL: http://svn.apache.org/viewvc?rev=760181&view=rev
Log:
csharp: Remove a BOM and CRLF line endings from some test code

Modified:
    incubator/thrift/trunk/test/csharp/CSharpClient.cs
    incubator/thrift/trunk/test/csharp/CSharpServer.cs

Modified: incubator/thrift/trunk/test/csharp/CSharpClient.cs
URL: http://svn.apache.org/viewvc/incubator/thrift/trunk/test/csharp/CSharpClient.cs?rev=760181&r1=760180&r2=760181&view=diff
==============================================================================
--- incubator/thrift/trunk/test/csharp/CSharpClient.cs (original)
+++ incubator/thrift/trunk/test/csharp/CSharpClient.cs Mon Mar 30 21:22:52 2009
@@ -1,68 +1,68 @@
-using System;
-using Thrift;
-using Thrift.Protocol;
-using Thrift.Server;
-using Thrift.Transport;
-
-
-namespace CSharpTutorial
-{
-    public class CSharpClient
-    {
-        public static void Main()
-        {
-            try
-            {
-                TTransport transport = new TSocket("localhost", 9090);
-                TProtocol protocol = new TBinaryProtocol(transport);
-                Calculator.Client client = new Calculator.Client(protocol);
-
-                transport.Open();
-
-                client.ping();
-                Console.WriteLine("ping()");
-
-                int sum = client.add(1, 1);
-                Console.WriteLine("1+1={0}", sum);
-
-                Work work = new Work();
-
-                work.op = Operation.DIVIDE;
-                work.num1 = 1;
-                work.num2 = 0;
-                try
-                {
-                    int quotient = client.calculate(1, work);
-                    Console.WriteLine("Whoa we can divide by 0");
-                }
-                catch (InvalidOperation io)
-                {
-                    Console.WriteLine("Invalid operation: " + io.why);
-                }
-
-                work.op = Operation.SUBTRACT;
-                work.num1 = 15;
-                work.num2 = 10;
-                try
-                {
-                    int diff = client.calculate(1, work);
-                    Console.WriteLine("15-10={0}", diff);
-                }
-                catch (InvalidOperation io)
-                {
-                    Console.WriteLine("Invalid operation: " + io.why);
-                }
-
-                SharedStruct log = client.getStruct(1);
-                Console.WriteLine("Check log: {0}", log.value);
-
-                transport.Close();
-            }
-            catch (TApplicationException x)
-            {
-                Console.WriteLine(x.StackTrace);
-            }
-
-        }
-    }
-}
\ No newline at end of file
+using System;
+using Thrift;
+using Thrift.Protocol;
+using Thrift.Server;
+using Thrift.Transport;
+
+
+namespace CSharpTutorial
+{
+    public class CSharpClient
+    {
+        public static void Main()
+        {
+            try
+            {
+                TTransport transport = new TSocket("localhost", 9090);
+                TProtocol protocol = new TBinaryProtocol(transport);
+                Calculator.Client client = new Calculator.Client(protocol);
+
+                transport.Open();
+
+                client.ping();
+                Console.WriteLine("ping()");
+
+                int sum = client.add(1, 1);
+                Console.WriteLine("1+1={0}", sum);
+
+                Work work = new Work();
+
+                work.op = Operation.DIVIDE;
+                work.num1 = 1;
+                work.num2 = 0;
+                try
+                {
+                    int quotient = client.calculate(1, work);
+                    Console.WriteLine("Whoa we can divide by 0");
+                }
+                catch (InvalidOperation io)
+                {
+                    Console.WriteLine("Invalid operation: " + io.why);
+                }
+
+                work.op = Operation.SUBTRACT;
+                work.num1 = 15;
+                work.num2 = 10;
+                try
+                {
+                    int diff = client.calculate(1, work);
+                    Console.WriteLine("15-10={0}", diff);
+                }
+                catch (InvalidOperation io)
+                {
+                    Console.WriteLine("Invalid operation: " + io.why);
+                }
+
+                SharedStruct log = client.getStruct(1);
+                Console.WriteLine("Check log: {0}", log.value);
+
+                transport.Close();
+            }
+            catch (TApplicationException x)
+            {
+                Console.WriteLine(x.StackTrace);
+            }
+
+        }
+    }
+}

Modified: incubator/thrift/trunk/test/csharp/CSharpServer.cs
URL: http://svn.apache.org/viewvc/incubator/thrift/trunk/test/csharp/CSharpServer.cs?rev=760181&r1=760180&r2=760181&view=diff
==============================================================================
--- incubator/thrift/trunk/test/csharp/CSharpServer.cs (original)
+++ incubator/thrift/trunk/test/csharp/CSharpServer.cs Mon Mar 30 21:22:52 2009
@@ -1,110 +1,110 @@
-using System;
-using System.Collections.Generic;
-using Thrift.Server;
-using Thrift.Transport;
-
-namespace CSharpTutorial
-{
-    public class CalculatorHandler : Calculator.Iface
-    {
-        Dictionary<int, SharedStruct> log;
-
-        public CalculatorHandler()
-        {
-            log = new Dictionary<int, SharedStruct>();
-        }
-
-        public void ping()
-        {
-            Console.WriteLine("ping()");
-        }
-
-        public int add(int n1, int n2)
-        {
-            Console.WriteLine("add({0},{1})", n1, n2);
-            return n1 + n2;
-        }
-
-        public int calculate(int logid, Work work)
-        {
-            Console.WriteLine("calculate({0}, [{1},{2},{3}])", logid, work.op, work.num1, work.num2);
-            int val = 0;
-            switch (work.op)
-            {
-                case Operation.ADD:
-                    val = work.num1 + work.num2;
-                    break;
-
-                case Operation.SUBTRACT:
-                    val = work.num1 - work.num2;
-                    break;
-
-                case Operation.MULTIPLY:
-                    val = work.num1 * work.num2;
-                    break;
-
-                case Operation.DIVIDE:
-                    if (work.num2 == 0)
-                    {
-                        InvalidOperation io = new InvalidOperation();
-                        io.what = (int)work.op;
-                        io.why = "Cannot divide by 0";
-                        throw io;
-                    }
-                    val = work.num1 / work.num2;
-                    break;
-
-                default:
-                    {
-                        InvalidOperation io = new InvalidOperation();
-                        io.what = (int)work.op;
-                        io.why = "Unknown operation";
-                        throw io;
-                    }
-            }
-
-            SharedStruct entry = new SharedStruct();
-            entry.key = logid;
-            entry.value = val.ToString();
-            log[logid] = entry;
-
-            return val;
-        }
-
-        public SharedStruct getStruct(int key)
-        {
-            Console.WriteLine("getStruct({0})", key);
-            return log[key];
-        }
-
-        public void zip()
-        {
-            Console.WriteLine("zip()");
-        }
-    }
-
-    public class CSharpServer
-    {
-        public static void Main()
-        {
-            try
-            {
-                CalculatorHandler handler = new CalculatorHandler();
-                Calculator.Processor processor = new Calculator.Processor(handler);
-                TServerTransport serverTransport = new TServerSocket(9090);
-                TServer server = new TSimpleServer(processor, serverTransport);
-
-                // Use this for a multithreaded server
-                // server = new TThreadPoolServer(processor, serverTransport);
-
-                Console.WriteLine("Starting the server...");
-                server.Serve();
-            }
-            catch (Exception x)
-            {
-                Console.WriteLine(x.StackTrace);
-            }
-            Console.WriteLine("done.");
-        }
-    }
-}
+using System;
+using System.Collections.Generic;
+using Thrift.Server;
+using Thrift.Transport;
+
+namespace CSharpTutorial
+{
+    public class CalculatorHandler : Calculator.Iface
+    {
+        Dictionary<int, SharedStruct> log;
+
+        public CalculatorHandler()
+        {
+            log = new Dictionary<int, SharedStruct>();
+        }
+
+        public void ping()
+        {
+            Console.WriteLine("ping()");
+        }
+
+        public int add(int n1, int n2)
+        {
+            Console.WriteLine("add({0},{1})", n1, n2);
+            return n1 + n2;
+        }
+
+        public int calculate(int logid, Work work)
+        {
+            Console.WriteLine("calculate({0}, [{1},{2},{3}])", logid, work.op, work.num1, work.num2);
+            int val = 0;
+            switch (work.op)
+            {
+                case Operation.ADD:
+                    val = work.num1 + work.num2;
+                    break;
+
+                case Operation.SUBTRACT:
+                    val = work.num1 - work.num2;
+                    break;
+
+                case Operation.MULTIPLY:
+                    val = work.num1 * work.num2;
+                    break;
+
+                case Operation.DIVIDE:
+                    if (work.num2 == 0)
+                    {
+                        InvalidOperation io = new InvalidOperation();
+                        io.what = (int)work.op;
+                        io.why = "Cannot divide by 0";
+                        throw io;
+                    }
+                    val = work.num1 / work.num2;
+                    break;
+
+                default:
+                    {
+                        InvalidOperation io = new InvalidOperation();
+                        io.what = (int)work.op;
+                        io.why = "Unknown operation";
+                        throw io;
+                    }
+            }
+
+            SharedStruct entry = new SharedStruct();
+            entry.key = logid;
+            entry.value = val.ToString();
+            log[logid] = entry;
+
+            return val;
+        }
+
+        public SharedStruct getStruct(int key)
+        {
+            Console.WriteLine("getStruct({0})", key);
+            return log[key];
+        }
+
+        public void zip()
+        {
+            Console.WriteLine("zip()");
+        }
+    }
+
+    public class CSharpServer
+    {
+        public static void Main()
+        {
+            try
+            {
+                CalculatorHandler handler = new CalculatorHandler();
+                Calculator.Processor processor = new Calculator.Processor(handler);
+                TServerTransport serverTransport = new TServerSocket(9090);
+                TServer server = new TSimpleServer(processor, serverTransport);
+
+                // Use this for a multithreaded server
+                // server = new TThreadPoolServer(processor, serverTransport);
+
+                Console.WriteLine("Starting the server...");
+                server.Serve();
+            }
+            catch (Exception x)
+            {
+                Console.WriteLine(x.StackTrace);
+            }
+            Console.WriteLine("done.");
+        }
+    }
+}