MimeTextMatch.cs 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. //
  2. // System.Web.Services.Description.MimeTextMatch.cs
  3. //
  4. // Author:
  5. // Tim Coleman ([email protected])
  6. //
  7. // Copyright (C) Tim Coleman, 2002
  8. //
  9. //
  10. // Permission is hereby granted, free of charge, to any person obtaining
  11. // a copy of this software and associated documentation files (the
  12. // "Software"), to deal in the Software without restriction, including
  13. // without limitation the rights to use, copy, modify, merge, publish,
  14. // distribute, sublicense, and/or sell copies of the Software, and to
  15. // permit persons to whom the Software is furnished to do so, subject to
  16. // the following conditions:
  17. //
  18. // The above copyright notice and this permission notice shall be
  19. // included in all copies or substantial portions of the Software.
  20. //
  21. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  22. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  23. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  24. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  25. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  26. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  27. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  28. //
  29. using System.ComponentModel;
  30. using System.Xml.Serialization;
  31. namespace System.Web.Services.Description {
  32. public sealed class MimeTextMatch {
  33. #region Fields
  34. int capture;
  35. int group;
  36. bool ignoreCase;
  37. MimeTextMatchCollection matches;
  38. string name;
  39. string pattern;
  40. int repeats;
  41. string type;
  42. #endregion // Fields
  43. #region Constructors
  44. public MimeTextMatch ()
  45. {
  46. capture = 0;
  47. group = 1;
  48. ignoreCase = false;
  49. matches = null;
  50. name = String.Empty;
  51. pattern = String.Empty;
  52. repeats = 1;
  53. type = String.Empty;
  54. }
  55. #endregion // Constructors
  56. #region Properties
  57. [DefaultValue (0)]
  58. [XmlAttribute ("capture")]
  59. public int Capture {
  60. get { return capture; }
  61. set {
  62. if (value < 0)
  63. throw new ArgumentException ();
  64. capture = value;
  65. }
  66. }
  67. [DefaultValue (1)]
  68. [XmlAttribute ("group")]
  69. public int Group {
  70. get { return group; }
  71. set {
  72. if (value < 0)
  73. throw new ArgumentException ();
  74. group = value;
  75. }
  76. }
  77. [XmlAttribute ("ignoreCase")]
  78. public bool IgnoreCase {
  79. get { return ignoreCase; }
  80. set { ignoreCase = value; }
  81. }
  82. [XmlElement ("match")]
  83. public MimeTextMatchCollection Matches {
  84. get { return matches; }
  85. }
  86. [XmlAttribute ("name")]
  87. public string Name {
  88. get { return name; }
  89. set { name = value; }
  90. }
  91. [XmlAttribute ("pattern")]
  92. public string Pattern {
  93. get { return pattern; }
  94. set { pattern = value; }
  95. }
  96. [XmlIgnore]
  97. public int Repeats {
  98. get { return repeats; }
  99. set {
  100. if (value < 0)
  101. throw new ArgumentException ();
  102. repeats = value;
  103. }
  104. }
  105. [DefaultValue ("1")]
  106. [XmlAttribute ("repeats")]
  107. public string RepeatsString {
  108. get { return Repeats.ToString (); }
  109. set { Repeats = Int32.Parse (value); }
  110. }
  111. [XmlAttribute ("type")]
  112. public string Type {
  113. get { return type; }
  114. set { type = value; }
  115. }
  116. #endregion // Properties
  117. #region Methods
  118. internal void SetParent (MimeTextMatchCollection matches)
  119. {
  120. this.matches = matches;
  121. }
  122. #endregion // Methods
  123. }
  124. }