static void Main(string[] args) { ICalculate calc = FactoryMethods.GetCalculateObject(1); int x = calc.Add(2, 2); Console.WriteLine(x); Console.ReadKey(); }
static void Main(string[] args) { ICalculate calculate = new ICalculate(); int result; result = calculate.Add(26, 54); Console.WriteLine(result); result = calculate.Div(26, 54); Console.WriteLine(result); result = calculate.Sub(26, 54); Console.WriteLine(result); result = calculate.Div(26, 54); Console.WriteLine(result); }
static void Main(string[] args) { NetTcpBinding binding = new NetTcpBinding(); binding.TransferMode = TransferMode.Streamed; binding.Security.Mode = SecurityMode.None; //binding.Security.Mode = SecurityMode.Transport; //binding.Security.Transport.ClientCredentialType = TcpClientCredentialType.Windows; EndpointAddress endpointAddress = new EndpointAddress(@"net.tcp://localhost:8089/nettcp"); ICalculate client = ChannelFactory <ICalculate> .CreateChannel(binding, endpointAddress); //new MyClientImplementation(NetTcp, BaseAddress); Console.WriteLine("Invoking CalculatorService at {0}", endpointAddress); double value1 = 100.00D; double value2 = 15.99D; // Call the Add service operation. double result = client.Add(value1, value2); Console.WriteLine("Add({0},{1}) = {2}", value1, value2, result); // Call the Subtract service operation. result = client.Substract(value1, value2); Console.WriteLine("Subtract({0},{1}) = {2}", value1, value2, result); // Call the Multiply service operation. result = client.multiply(value1, value2); Console.WriteLine("Multiply({0},{1}) = {2}", value1, value2, result); result = client.Action(new Inputs() { A = 100, B = 30, Operation = Inputs.OperationEnum.Multiplication }); Console.WriteLine("Action with DataModel {0}", result); //Closing the client gracefully closes the connection and cleans up resources ((IClientChannel)client).Close(); Console.WriteLine("Closed Proxy"); }
public static double basicOp(char operation, double value1, double value2) { _calculate = new Calculate(); switch (operation) { case '+': return(_calculate.Add(value1, value2)); case '-': return(_calculate.Subtract(value1, value2)); case '*': return(_calculate.Multiply(value1, value2)); case '/': return(_calculate.Divide(value1, value2)); default: return(-1); } }
public void AddTest() { _calculate = new Calculate(); Assert.AreEqual(expected: _calculate.Add(4, 7), 11); }
public int Index(int a, int b) { var sum = _math.Add(a, b); return(sum); }