XmlSchemaParticle.cs 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. // Author: Dwivedi, Ajay kumar
  2. // [email protected]
  3. using System;
  4. using System.Xml.Serialization;
  5. namespace System.Xml.Schema
  6. {
  7. /// <summary>
  8. /// Summary description for XmlSchemaParticle.
  9. /// </summary>
  10. public abstract class XmlSchemaParticle : XmlSchemaAnnotated
  11. {
  12. decimal minOccurs, maxOccurs;
  13. string minstr, maxstr;
  14. protected XmlSchemaParticle()
  15. {
  16. minOccurs = decimal.One;
  17. maxOccurs = decimal.One;
  18. }
  19. #region Attributes
  20. [System.Xml.Serialization.XmlAttribute("minOccurs")]
  21. public string MinOccursString
  22. {
  23. get{ return minstr; }
  24. set
  25. {
  26. decimal val = decimal.Parse(value);
  27. if(val >= 0 && (val == Decimal.Truncate(val)))
  28. {
  29. minOccurs = val;
  30. minstr = val.ToString();
  31. }
  32. else
  33. {
  34. throw new XmlSchemaException
  35. ("MinOccursString must be a non-negative number",null);
  36. }
  37. }
  38. }
  39. [System.Xml.Serialization.XmlAttribute("maxOccurs")]
  40. public string MaxOccursString
  41. {
  42. get{ return maxstr; }
  43. set
  44. {
  45. if(value == "unbounded")
  46. {
  47. maxstr = value;
  48. maxOccurs = decimal.MaxValue;
  49. }
  50. else
  51. {
  52. decimal val = decimal.Parse(value);
  53. if(val >= 0 && (val == Decimal.Truncate(val)))
  54. {
  55. maxOccurs = val;
  56. maxstr = val.ToString();
  57. }
  58. else
  59. {
  60. throw new XmlSchemaException
  61. ("MaxOccurs must be a non-negative integer",null);
  62. }
  63. }
  64. }
  65. }
  66. #endregion
  67. #region XmlIgnore
  68. [XmlIgnore]
  69. public decimal MinOccurs
  70. {
  71. get{ return minOccurs; }
  72. set
  73. {
  74. MinOccursString = value.ToString();
  75. }
  76. }
  77. [XmlIgnore]
  78. public decimal MaxOccurs
  79. {
  80. get{ return maxOccurs; }
  81. set
  82. {
  83. MaxOccursString = value.ToString();
  84. }
  85. }
  86. #endregion
  87. }
  88. }