SharedRuntimeState.cs 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) Microsoft Corporation. All rights reserved.
  3. //-----------------------------------------------------------------------------
  4. namespace System.ServiceModel.Dispatcher
  5. {
  6. using System;
  7. class SharedRuntimeState
  8. {
  9. bool isImmutable;
  10. bool enableFaults = true;
  11. bool isOnServer;
  12. bool manualAddressing;
  13. bool validateMustUnderstand = true;
  14. internal SharedRuntimeState(bool isOnServer)
  15. {
  16. this.isOnServer = isOnServer;
  17. }
  18. internal bool EnableFaults
  19. {
  20. get { return this.enableFaults; }
  21. set { this.enableFaults = value; }
  22. }
  23. internal bool IsOnServer
  24. {
  25. get { return this.isOnServer; }
  26. }
  27. internal bool ManualAddressing
  28. {
  29. get { return this.manualAddressing; }
  30. set { this.manualAddressing = value; }
  31. }
  32. internal bool ValidateMustUnderstand
  33. {
  34. get { return this.validateMustUnderstand; }
  35. set { this.validateMustUnderstand = value; }
  36. }
  37. internal void LockDownProperties()
  38. {
  39. this.isImmutable = true;
  40. }
  41. internal void ThrowIfImmutable()
  42. {
  43. if (this.isImmutable)
  44. {
  45. if (this.IsOnServer)
  46. {
  47. throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.SFxImmutableServiceHostBehavior0)));
  48. }
  49. else
  50. {
  51. throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.SFxImmutableChannelFactoryBehavior0)));
  52. }
  53. }
  54. }
  55. }
  56. }