Пример #1
0
        public void ApplyDispatchBehavior(ServiceDescription serviceDescription,
                                          ServiceHostBase serviceHostBase)
        {
            LoggingParameterInspector paramInspector = new LoggingParameterInspector
            {
                ServiceType     = serviceDescription.ServiceType,
                LoggingStrategy = GetLoggingStrategy(),
                Log             = Log,
                LogAfterCall    = LogAfterCall,
                LogBeforeCall   = LogBeforeCall,
                LogErrors       = LogErrors,
                LogWarnings     = LogWarnings,
                LogInformation  = LogInformation,
                LogArguments    = LogArguments,
                LogReturnVal    = LogReturnVal
            };

            foreach (ChannelDispatcher chDisp in serviceHostBase.ChannelDispatchers)
            {
                foreach (EndpointDispatcher epDisp in chDisp.Endpoints)
                {
                    foreach (DispatchOperation op in epDisp.DispatchRuntime.Operations)
                    {
                        op.ParameterInspectors.Add(paramInspector);
                    }
                }
            }
        }
Пример #2
0
        public void ApplyDispatchBehavior(OperationDescription operationDescription,
                                          DispatchOperation dispatchOperation)
        {
            LoggingParameterInspector paramInspector =
                dispatchOperation.ParameterInspectors.FirstOrDefault(
                    pi => pi.GetType() == typeof(LoggingParameterInspector)) as LoggingParameterInspector;

            if (paramInspector != null)
            {
                // The logging inspector already exist...

                dispatchOperation.ParameterInspectors.Remove(paramInspector);
            }

            paramInspector = new LoggingParameterInspector
            {
                ServiceType     = operationDescription.DeclaringContract.ContractType,
                LoggingStrategy = GetLoggingStrategy(),
                Log             = Log,
                LogAfterCall    = LogAfterCall,
                LogBeforeCall   = LogBeforeCall,
                LogErrors       = LogErrors,
                LogWarnings     = LogWarnings,
                LogInformation  = LogInformation,
                LogArguments    = LogArguments,
                LogReturnVal    = LogReturnVal
            };

            dispatchOperation.ParameterInspectors.Add(paramInspector);
        }
Пример #3
0
        public void ApplyClientBehavior(OperationDescription operationDescription,
                                        ClientOperation clientOperation)
        {
            LoggingParameterInspector paramInspector = new LoggingParameterInspector
            {
                ServiceType     = operationDescription.DeclaringContract.ContractType,
                LoggingStrategy = GetLoggingStrategy(),
                Log             = Log,
                LogAfterCall    = LogAfterCall,
                LogBeforeCall   = LogBeforeCall,
                LogErrors       = LogErrors,
                LogWarnings     = LogWarnings,
                LogInformation  = LogInformation,
                LogArguments    = LogArguments,
                LogReturnVal    = LogReturnVal
            };

            clientOperation.ParameterInspectors.Add(paramInspector);
        }