//Apply the custom IInstanceContextProvider to the EndpointDispatcher.DispatchRuntime public void ApplyDispatchBehavior(ServiceDescription description, ServiceHostBase serviceHostBase) { CalculatorExtension extension = new CalculatorExtension(); foreach (ChannelDispatcherBase dispatcherBase in serviceHostBase.ChannelDispatchers) { ChannelDispatcher dispatcher = dispatcherBase as ChannelDispatcher; foreach (EndpointDispatcher endpointDispatcher in dispatcher.Endpoints) { endpointDispatcher.DispatchRuntime.InstanceContextProvider = extension; endpointDispatcher.DispatchRuntime.MessageInspectors.Add(extension); } } }
public void DivideTwoNumbersExt() { double result = CalculatorExtension.Getresult("divide", 4, 2); Assert.AreEqual(2, result); }
public void SubtractTwoNumbersExt() { double result = CalculatorExtension.Getresult("subtract", 3, 2); Assert.AreEqual(1, result); }
public void MultiplyTwoNumbersExt() { double result = CalculatorExtension.Getresult("multiply", 1, 2); Assert.AreEqual(2, result); }
public void AddTwoNumbersExt() { double result = CalculatorExtension.Getresult("add", 1, 2); Assert.AreEqual(3, result); }