2
0

MessageContractMemberAttribute.cs 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) Microsoft Corporation. All rights reserved.
  3. //-----------------------------------------------------------------------------
  4. namespace System.ServiceModel
  5. {
  6. using System.Runtime.Serialization;
  7. using System.ServiceModel.Channels;
  8. using System.ServiceModel.Description;
  9. using System.ServiceModel.Security;
  10. using System.Net.Security;
  11. public abstract class MessageContractMemberAttribute : Attribute
  12. {
  13. string name;
  14. string ns;
  15. bool isNameSetExplicit;
  16. bool isNamespaceSetExplicit;
  17. ProtectionLevel protectionLevel = ProtectionLevel.None;
  18. bool hasProtectionLevel = false;
  19. internal const string NamespacePropertyName = "Namespace";
  20. public string Namespace
  21. {
  22. get { return ns; }
  23. set
  24. {
  25. if (value == null)
  26. {
  27. throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("value");
  28. }
  29. if (value.Length > 0)
  30. {
  31. NamingHelper.CheckUriProperty(value, "Namespace");
  32. }
  33. ns = value;
  34. isNamespaceSetExplicit = true;
  35. }
  36. }
  37. internal bool IsNamespaceSetExplicit
  38. {
  39. get { return isNamespaceSetExplicit; }
  40. }
  41. internal const string NamePropertyName = "Name";
  42. public string Name
  43. {
  44. get { return name; }
  45. set
  46. {
  47. if (value == null)
  48. {
  49. throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("value");
  50. }
  51. if (value == string.Empty)
  52. {
  53. throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("value",
  54. SR.GetString(SR.SFxNameCannotBeEmpty)));
  55. }
  56. name = value; isNameSetExplicit = true;
  57. }
  58. }
  59. internal bool IsNameSetExplicit
  60. {
  61. get { return isNameSetExplicit; }
  62. }
  63. internal const string ProtectionLevelPropertyName = "ProtectionLevel";
  64. public ProtectionLevel ProtectionLevel
  65. {
  66. get
  67. {
  68. return this.protectionLevel;
  69. }
  70. set
  71. {
  72. if (!ProtectionLevelHelper.IsDefined(value))
  73. throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("value"));
  74. this.protectionLevel = value;
  75. this.hasProtectionLevel = true;
  76. }
  77. }
  78. public bool HasProtectionLevel
  79. {
  80. get { return this.hasProtectionLevel; }
  81. }
  82. }
  83. }