public object BeforeSendRequest(ref Message request, IClientChannel channel) { MyChannelExtension extension = channel.Extensions.Find <MyChannelExtension>(); if (extension != null && extension.IntroduceErrors) { this.IntroduceErrorToMessage(ref request); } return(null); }
static void DoCalculations(ICalculator proxy) { MyChannelExtension extension = ((IContextChannel)proxy).Extensions.Find <MyChannelExtension>(); if (extension != null) { if (extension.Binding != null) { Console.WriteLine("Sending requests over {0}", extension.Binding.Scheme); } if (extension.IntroduceErrors) { Console.WriteLine("Errors will be introduced in the request"); } } // Call the Add service operation. double value1 = 100.00D; double value2 = 15.99D; double result = proxy.Add(value1, value2); Console.WriteLine("Add({0},{1}) = {2}", value1, value2, result); // Call the Subtract service operation. value1 = 145.00D; value2 = 76.54D; result = proxy.Subtract(value1, value2); Console.WriteLine("Subtract({0},{1}) = {2}", value1, value2, result); // Call the Multiply service operation. value1 = 9.00D; value2 = 81.25D; result = proxy.Multiply(value1, value2); Console.WriteLine("Multiply({0},{1}) = {2}", value1, value2, result); // Call the Divide service operation. value1 = 22.00D; value2 = 7.00D; result = proxy.Divide(value1, value2); Console.WriteLine("Divide({0},{1}) = {2}", value1, value2, result); Console.WriteLine(); }