MessageContractAttribute.cs 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. //------------------------------------------------------------
  2. // Copyright (c) Microsoft Corporation. All rights reserved.
  3. //------------------------------------------------------------
  4. namespace System.ServiceModel
  5. {
  6. using System.Reflection;
  7. using System.ServiceModel.Channels;
  8. using System.Net.Security;
  9. using System.ServiceModel.Security;
  10. using System.ServiceModel.Description;
  11. [AttributeUsage(ServiceModelAttributeTargets.MessageContract, AllowMultiple = false)]
  12. public sealed class MessageContractAttribute : Attribute
  13. {
  14. bool isWrapped = true;
  15. string wrappedName;
  16. string wrappedNs;
  17. ProtectionLevel protectionLevel = ProtectionLevel.None;
  18. bool hasProtectionLevel = false;
  19. internal const string ProtectionLevelPropertyName = "ProtectionLevel";
  20. public ProtectionLevel ProtectionLevel
  21. {
  22. get
  23. {
  24. return this.protectionLevel;
  25. }
  26. set
  27. {
  28. if (!ProtectionLevelHelper.IsDefined(value))
  29. throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("value"));
  30. this.protectionLevel = value;
  31. this.hasProtectionLevel = true;
  32. }
  33. }
  34. public bool HasProtectionLevel
  35. {
  36. get { return this.hasProtectionLevel; }
  37. }
  38. public bool IsWrapped
  39. {
  40. get { return isWrapped; }
  41. set { isWrapped = value; }
  42. }
  43. public string WrapperName
  44. {
  45. get
  46. {
  47. return wrappedName;
  48. }
  49. set
  50. {
  51. if (value == null)
  52. throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("value");
  53. if (value == string.Empty)
  54. throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("value",
  55. SR.GetString(SR.SFxWrapperNameCannotBeEmpty)));
  56. wrappedName = value;
  57. }
  58. }
  59. public string WrapperNamespace
  60. {
  61. get
  62. {
  63. return wrappedNs;
  64. }
  65. set
  66. {
  67. if (!string.IsNullOrEmpty(value))
  68. NamingHelper.CheckUriProperty(value, "WrapperNamespace");
  69. wrappedNs = value;
  70. }
  71. }
  72. }
  73. }