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