SoapAttributes.cs 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. //
  2. // SoapAttributes.cs:
  3. //
  4. // Author:
  5. // John Donagher ([email protected])
  6. //
  7. // (C) 2002 John Donagher
  8. //
  9. using System.Reflection;
  10. using System;
  11. using System.ComponentModel;
  12. namespace System.Xml.Serialization
  13. {
  14. /// <summary>
  15. /// Summary description for SoapAttributes.
  16. /// </summary>
  17. public class SoapAttributes
  18. {
  19. private SoapAttributeAttribute soapAttribute;
  20. private object soapDefaultValue = System.DBNull.Value;
  21. private SoapElementAttribute soapElement;
  22. private SoapEnumAttribute soapEnum;
  23. private bool soapIgnore;
  24. private SoapTypeAttribute soapType;
  25. public SoapAttributes ()
  26. {
  27. }
  28. public SoapAttributes (ICustomAttributeProvider provider)
  29. {
  30. object[] attributes = provider.GetCustomAttributes(false);
  31. foreach(object obj in attributes)
  32. {
  33. if(obj is SoapAttributeAttribute)
  34. soapAttribute = (SoapAttributeAttribute) obj;
  35. else if(obj is DefaultValueAttribute)
  36. soapDefaultValue = obj;
  37. else if(obj is SoapElementAttribute)
  38. soapElement = (SoapElementAttribute) obj;
  39. else if(obj is SoapEnumAttribute)
  40. soapEnum = (SoapEnumAttribute) obj;
  41. else if(obj is SoapIgnoreAttribute)
  42. soapIgnore = true;
  43. else if(obj is SoapTypeAttribute)
  44. soapType = (SoapTypeAttribute) obj;
  45. }
  46. }
  47. public SoapAttributeAttribute SoapAttribute
  48. {
  49. get { return soapAttribute; }
  50. set { soapAttribute = value; }
  51. }
  52. public object SoapDefaultValue
  53. {
  54. get { return soapDefaultValue; }
  55. set { soapDefaultValue = value; }
  56. }
  57. public SoapElementAttribute SoapElement
  58. {
  59. get { return soapElement; }
  60. set { soapElement = value; }
  61. }
  62. public SoapEnumAttribute SoapEnum
  63. {
  64. get { return soapEnum; }
  65. set { soapEnum = value; }
  66. }
  67. public bool SoapIgnore
  68. {
  69. get { return soapIgnore; }
  70. set { soapIgnore = value; }
  71. }
  72. public SoapTypeAttribute SoapType
  73. {
  74. get { return soapType; }
  75. set { soapType = value; }
  76. }
  77. internal void AddKeyHash (System.Text.StringBuilder sb)
  78. {
  79. sb.Append ("SA ");
  80. if (soapIgnore)
  81. sb.Append ('i');
  82. if (soapAttribute != null)
  83. soapAttribute.AddKeyHash (sb);
  84. if (soapElement != null)
  85. soapElement.AddKeyHash (sb);
  86. if (soapEnum != null)
  87. soapEnum.AddKeyHash (sb);
  88. if (soapType != null)
  89. soapType.AddKeyHash (sb);
  90. if (soapDefaultValue == null) {
  91. sb.Append ("n");
  92. }
  93. else if (!(soapDefaultValue is System.DBNull)) {
  94. string v = XmlCustomFormatter.ToXmlString (TypeTranslator.GetTypeData (soapDefaultValue.GetType()), soapDefaultValue);
  95. sb.Append ("v" + v);
  96. }
  97. sb.Append ("|");
  98. }
  99. }
  100. }