CallbackDebugBehavior.cs 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. //------------------------------------------------------------
  2. // Copyright (c) Microsoft Corporation. All rights reserved.
  3. //------------------------------------------------------------
  4. namespace System.ServiceModel.Description
  5. {
  6. using System.ServiceModel.Channels;
  7. using System.ServiceModel;
  8. using System.ServiceModel.Dispatcher;
  9. using System.Runtime.Serialization;
  10. using System.Collections.ObjectModel;
  11. using System.Collections.Generic;
  12. public class CallbackDebugBehavior : IEndpointBehavior
  13. {
  14. bool includeExceptionDetailInFaults = false;
  15. public CallbackDebugBehavior(bool includeExceptionDetailInFaults)
  16. {
  17. this.includeExceptionDetailInFaults = includeExceptionDetailInFaults;
  18. }
  19. public bool IncludeExceptionDetailInFaults
  20. {
  21. get { return this.includeExceptionDetailInFaults; }
  22. set { this.includeExceptionDetailInFaults = value; }
  23. }
  24. void IEndpointBehavior.Validate(ServiceEndpoint serviceEndpoint)
  25. {
  26. }
  27. void IEndpointBehavior.AddBindingParameters(ServiceEndpoint serviceEndpoint, BindingParameterCollection bindingParameters)
  28. {
  29. }
  30. void IEndpointBehavior.ApplyDispatchBehavior(ServiceEndpoint serviceEndpoint, EndpointDispatcher endpointDispatcher)
  31. {
  32. throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(
  33. SR.GetString(SR.SFXEndpointBehaviorUsedOnWrongSide, typeof(CallbackDebugBehavior).Name)));
  34. }
  35. void IEndpointBehavior.ApplyClientBehavior(ServiceEndpoint serviceEndpoint, ClientRuntime behavior)
  36. {
  37. ChannelDispatcher channelDispatcher = behavior.CallbackDispatchRuntime.ChannelDispatcher;
  38. if (channelDispatcher != null && this.includeExceptionDetailInFaults)
  39. {
  40. channelDispatcher.IncludeExceptionDetailInFaults = true;
  41. }
  42. }
  43. }
  44. }