diff options
author | Halil İbrahim Kalkan <hi_kalkan@yahoo.com> | 2013-04-08 21:44:58 +0300 |
---|---|---|
committer | Halil İbrahim Kalkan <hi_kalkan@yahoo.com> | 2013-04-08 21:44:58 +0300 |
commit | 79953cb56cda204f190ffcd9995b27ebea25e62d (patch) | |
tree | de939755c2e32eaa5fa3e41e21114e1c727ed0a4 /samples/SimpleCalculatorSystem/CalculatorServer/Program.cs | |
parent | 934c543eb6b0bd7173038e45a7dac0241d091da4 (diff) | |
download | scs-79953cb56cda204f190ffcd9995b27ebea25e62d.zip scs-79953cb56cda204f190ffcd9995b27ebea25e62d.tar.gz scs-79953cb56cda204f190ffcd9995b27ebea25e62d.tar.bz2 |
Adding to github
Adding to github
Diffstat (limited to 'samples/SimpleCalculatorSystem/CalculatorServer/Program.cs')
-rw-r--r-- | samples/SimpleCalculatorSystem/CalculatorServer/Program.cs | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/samples/SimpleCalculatorSystem/CalculatorServer/Program.cs b/samples/SimpleCalculatorSystem/CalculatorServer/Program.cs new file mode 100644 index 0000000..8ec07ef --- /dev/null +++ b/samples/SimpleCalculatorSystem/CalculatorServer/Program.cs @@ -0,0 +1,46 @@ +using System; +using CalculatorCommonLib; +using Hik.Communication.Scs.Communication.EndPoints.Tcp; +using Hik.Communication.ScsServices.Service; + +namespace CalculatorServer +{ + class Program + { + static void Main() + { + //Create a service application that runs on 10083 TCP port + var serviceApplication = ScsServiceBuilder.CreateService(new ScsTcpEndPoint(10083)); + + //Create a CalculatorService and add it to service application + serviceApplication.AddService<ICalculatorService, CalculatorService>(new CalculatorService()); + + //Start service application + serviceApplication.Start(); + + Console.WriteLine("Calculator service is started. Press enter to stop..."); + Console.ReadLine(); + + //Stop service application + serviceApplication.Stop(); + } + } + + public class CalculatorService : ScsService, ICalculatorService + { + public int Add(int number1, int number2) + { + return number1 + number2; + } + + public double Divide(double number1, double number2) + { + if(number2 == 0.0) + { + throw new DivideByZeroException("number2 can not be zero!"); + } + + return number1 / number2; + } + } +} |