XmlSchemaParticle.cs 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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("maxOccurs")]
  21. public string MaxOccursString
  22. {
  23. get{ return maxstr; }
  24. set
  25. {
  26. if(value == "unbounded")
  27. {
  28. maxstr = value;
  29. maxOccurs = decimal.MaxValue;
  30. }
  31. else
  32. {
  33. decimal val = decimal.Parse(value);
  34. if(val >= 0 && (val == Decimal.Truncate(val)))
  35. {
  36. maxOccurs = val;
  37. maxstr = value;
  38. }
  39. else
  40. {
  41. throw new XmlSchemaException
  42. ("MaxOccurs must be a non-negative integer",null);
  43. }
  44. }
  45. }
  46. }
  47. [System.Xml.Serialization.XmlAttribute("minOccurs")]
  48. public string MinOccursString
  49. {
  50. get{ return minstr; }
  51. set
  52. {
  53. decimal val = decimal.Parse(value);
  54. if(val >= 0 && (val == Decimal.Truncate(val)))
  55. {
  56. minOccurs = val;
  57. minstr = value;
  58. }
  59. else
  60. {
  61. throw new XmlSchemaException
  62. ("MinOccursString must be a non-negative number",null);
  63. }
  64. }
  65. }
  66. #endregion
  67. #region XmlIgnore
  68. [XmlIgnore]
  69. public decimal MaxOccurs
  70. {
  71. get{ return maxOccurs; }
  72. set
  73. {
  74. MaxOccursString = value.ToString();
  75. }
  76. }
  77. [XmlIgnore]
  78. public decimal MinOccurs
  79. {
  80. get{ return minOccurs; }
  81. set
  82. {
  83. MinOccursString = value.ToString();
  84. }
  85. }
  86. #endregion
  87. }
  88. }