public object AfterReceiveRequest(ref System.ServiceModel.Channels.Message request, System.ServiceModel.IClientChannel channel, System.ServiceModel.InstanceContext instanceContext) { MyStateContainer sc = OperationContext.Current.Host.Extensions.Find <MyStateContainer>(); Console.WriteLine("*** MessageInspector: {0} ***", sc.MyState); sc.MyState = "bar"; request = this.TraceMessage(request); return(null); }
public object BeforeCall(string operationName, object[] inputs) { MyStateContainer sc = OperationContext.Current.Host.Extensions.Find <MyStateContainer>(); Console.WriteLine("*** ParameterInspector: {0} ***", sc.MyState); sc.MyState = "baz"; if (!Regex.IsMatch(inputs[index] as string, @"\d{5}-\d{4}")) { throw new FaultException("Invalid zip code format...please use ddddd-dddd"); } return(null); }
public object Invoke(object instance, object[] inputs, out object[] outputs) { MyStateContainer sc = OperationContext.Current.Host.Extensions.Find <MyStateContainer>(); Console.WriteLine("*** OperationInvoker: {0} ***", sc.MyState); string zipCode = inputs[index] as string; string value; if (cachedValues.TryGetValue(zipCode, out value)) { outputs = new object[0]; return(value); } else { value = innerInvoker.Invoke(instance, inputs, out outputs) as string; cachedValues[zipCode] = value; return(value); } }