MessagePartDescription.cs 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. //------------------------------------------------------------
  2. // Copyright (c) Microsoft Corporation. All rights reserved.
  3. //------------------------------------------------------------
  4. namespace System.ServiceModel.Description
  5. {
  6. using System;
  7. using System.ComponentModel;
  8. using System.Diagnostics;
  9. using System.Net.Security;
  10. using System.Reflection;
  11. using System.ServiceModel.Security;
  12. [DebuggerDisplay("Name={name}, Namespace={ns}, Type={Type}, Index={index}}")]
  13. public class MessagePartDescription
  14. {
  15. XmlName name;
  16. string ns;
  17. int index;
  18. Type type;
  19. int serializationPosition;
  20. ProtectionLevel protectionLevel;
  21. bool hasProtectionLevel;
  22. MemberInfo memberInfo;
  23. ICustomAttributeProvider additionalAttributesProvider;
  24. bool multiple;
  25. string baseType;
  26. string uniquePartName;
  27. public MessagePartDescription(string name, string ns)
  28. {
  29. if (name == null)
  30. {
  31. throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("name", SR.GetString(SR.SFxParameterNameCannotBeNull));
  32. }
  33. this.name = new XmlName(name, true /*isEncoded*/);
  34. if (!string.IsNullOrEmpty(ns))
  35. {
  36. NamingHelper.CheckUriParameter(ns, "ns");
  37. }
  38. this.ns = ns;
  39. }
  40. internal MessagePartDescription(MessagePartDescription other)
  41. {
  42. this.name = other.name;
  43. this.ns = other.ns;
  44. this.index = other.index;
  45. this.type = other.type;
  46. this.serializationPosition = other.serializationPosition;
  47. this.hasProtectionLevel = other.hasProtectionLevel;
  48. this.protectionLevel = other.protectionLevel;
  49. this.memberInfo = other.memberInfo;
  50. this.multiple = other.multiple;
  51. this.additionalAttributesProvider = other.additionalAttributesProvider;
  52. this.baseType = other.baseType;
  53. this.uniquePartName = other.uniquePartName;
  54. }
  55. internal virtual MessagePartDescription Clone()
  56. {
  57. return new MessagePartDescription(this);
  58. }
  59. internal string BaseType
  60. {
  61. get { return this.baseType; }
  62. set { this.baseType = value; }
  63. }
  64. internal XmlName XmlName
  65. {
  66. get { return this.name; }
  67. }
  68. internal string CodeName
  69. {
  70. get { return this.name.DecodedName; }
  71. }
  72. public string Name
  73. {
  74. get { return this.name.EncodedName; }
  75. }
  76. public string Namespace
  77. {
  78. get { return this.ns; }
  79. }
  80. public Type Type
  81. {
  82. get { return type; }
  83. set { type = value; }
  84. }
  85. public int Index
  86. {
  87. get { return index; }
  88. set { index = value; }
  89. }
  90. [DefaultValue(false)]
  91. public bool Multiple
  92. {
  93. get { return this.multiple; }
  94. set { this.multiple = value; }
  95. }
  96. public ProtectionLevel ProtectionLevel
  97. {
  98. get { return this.protectionLevel; }
  99. set
  100. {
  101. if (!ProtectionLevelHelper.IsDefined(value))
  102. throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("value"));
  103. this.protectionLevel = value;
  104. this.hasProtectionLevel = true;
  105. }
  106. }
  107. public bool HasProtectionLevel
  108. {
  109. get { return this.hasProtectionLevel; }
  110. }
  111. public MemberInfo MemberInfo
  112. {
  113. get { return this.memberInfo; }
  114. set { this.memberInfo = value; }
  115. }
  116. internal ICustomAttributeProvider AdditionalAttributesProvider
  117. {
  118. get { return this.additionalAttributesProvider ?? this.memberInfo; }
  119. set { this.additionalAttributesProvider = value; }
  120. }
  121. internal string UniquePartName
  122. {
  123. get { return this.uniquePartName; }
  124. set { this.uniquePartName = value; }
  125. }
  126. internal int SerializationPosition
  127. {
  128. get { return serializationPosition; }
  129. set { serializationPosition = value; }
  130. }
  131. internal void ResetProtectionLevel()
  132. {
  133. this.protectionLevel = ProtectionLevel.None;
  134. this.hasProtectionLevel = false;
  135. }
  136. }
  137. }