FaultDescription.cs 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. //------------------------------------------------------------
  2. // Copyright (c) Microsoft Corporation. All rights reserved.
  3. //------------------------------------------------------------
  4. namespace System.ServiceModel.Description
  5. {
  6. using System.Collections.Generic;
  7. using System.Xml;
  8. using System.Runtime.Serialization;
  9. using System.CodeDom;
  10. using System.ServiceModel.Security;
  11. using System.Diagnostics;
  12. using System.Net.Security;
  13. [DebuggerDisplay("Name={name}, Action={action}, DetailType={detailType}")]
  14. public class FaultDescription
  15. {
  16. string action;
  17. Type detailType;
  18. CodeTypeReference detailTypeReference;
  19. XmlName elementName;
  20. XmlName name;
  21. string ns;
  22. ProtectionLevel protectionLevel;
  23. bool hasProtectionLevel;
  24. public FaultDescription(string action)
  25. {
  26. if (action == null)
  27. throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("action"));
  28. this.action = action;
  29. }
  30. public string Action
  31. {
  32. get { return action; }
  33. internal set { action = value; }
  34. }
  35. // Not serializable on purpose, metadata import/export cannot
  36. // produce it, only available when binding to runtime
  37. public Type DetailType
  38. {
  39. get { return detailType; }
  40. set { detailType = value; }
  41. }
  42. internal CodeTypeReference DetailTypeReference
  43. {
  44. get { return detailTypeReference; }
  45. set { detailTypeReference = value; }
  46. }
  47. public string Name
  48. {
  49. get { return name.EncodedName; }
  50. set { SetNameAndElement(new XmlName(value, true /*isEncoded*/)); }
  51. }
  52. public string Namespace
  53. {
  54. get { return ns; }
  55. set { ns = value; }
  56. }
  57. internal XmlName ElementName
  58. {
  59. get { return elementName; }
  60. set { elementName = value; }
  61. }
  62. public ProtectionLevel ProtectionLevel
  63. {
  64. get { return this.protectionLevel; }
  65. set
  66. {
  67. if (!ProtectionLevelHelper.IsDefined(value))
  68. throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("value"));
  69. this.protectionLevel = value;
  70. this.hasProtectionLevel = true;
  71. }
  72. }
  73. public bool ShouldSerializeProtectionLevel()
  74. {
  75. return this.HasProtectionLevel;
  76. }
  77. public bool HasProtectionLevel
  78. {
  79. get { return this.hasProtectionLevel; }
  80. }
  81. internal void ResetProtectionLevel()
  82. {
  83. this.protectionLevel = ProtectionLevel.None;
  84. this.hasProtectionLevel = false;
  85. }
  86. internal void SetNameAndElement(XmlName name)
  87. {
  88. this.elementName = this.name = name;
  89. }
  90. internal void SetNameOnly(XmlName name)
  91. {
  92. this.name = name;
  93. }
  94. }
  95. }