5 // Peter Van Isacker (sclytrack@planetinternet.be)
\r
6 // Rafael Teixeira (rafaelteixeirabr@hotmail.com)
\r
8 // (C) 2003 Peter Van Isacker, Rafael Teixeira
\r
12 // Permission is hereby granted, free of charge, to any person obtaining
\r
13 // a copy of this software and associated documentation files (the
\r
14 // "Software"), to deal in the Software without restriction, including
\r
15 // without limitation the rights to use, copy, modify, merge, publish,
\r
16 // distribute, sublicense, and/or sell copies of the Software, and to
\r
17 // permit persons to whom the Software is furnished to do so, subject to
\r
18 // the following conditions:
\r
20 // The above copyright notice and this permission notice shall be
\r
21 // included in all copies or substantial portions of the Software.
\r
23 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
\r
24 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
\r
25 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
\r
26 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
\r
27 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
\r
28 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
\r
29 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
\r
33 namespace System.Messaging
\r
35 public class MessageQueueCriteria
\r
37 public MessageQueueCriteria()
\r
42 private bool setCategory;
\r
43 private Guid category;
\r
44 public Guid Category
\r
49 throw new InvalidOperationException();
\r
55 setCategory = true;
\r
59 private bool setCreatedAfter;
\r
60 private DateTime createdAfter;
\r
61 public DateTime CreatedAfter
\r
65 if (!setCreatedAfter)
\r
66 throw new InvalidOperationException();
\r
67 return createdAfter;
\r
71 createdAfter = value;
\r
72 setCreatedAfter = true;
\r
76 private bool setCreatedBefore;
\r
77 private DateTime createdBefore;
\r
78 public DateTime CreatedBefore
\r
82 if (!setCreatedBefore)
\r
83 throw new InvalidOperationException();
\r
84 return createdBefore;
\r
88 createdBefore = value;
\r
89 setCreatedBefore = true;
\r
93 private bool setLabel;
\r
94 private string label;
\r
95 public string Label
\r
100 throw new InvalidOperationException();
\r
111 private bool invalidMachineName(string name)
\r
116 private bool setMachineName;
\r
117 private string machineName;
\r
118 public string MachineName
\r
122 if (!setMachineName)
\r
123 throw new InvalidOperationException();
\r
124 return machineName;
\r
128 if (invalidMachineName(value))
\r
129 throw new InvalidOperationException();
\r
130 machineName = value;
\r
131 setMachineName = true;
\r
135 private bool setModifiedAfter;
\r
136 private DateTime modifiedAfter;
\r
137 public DateTime ModifiedAfter
\r
141 if (!setModifiedAfter)
\r
142 throw new InvalidOperationException();
\r
143 return modifiedAfter;
\r
147 modifiedAfter = value;
\r
148 setModifiedAfter = true;
\r
152 private bool setModifiedBefore;
\r
153 private DateTime modifiedBefore;
\r
154 public DateTime ModifiedBefore
\r
158 if (!setModifiedBefore)
\r
159 throw new InvalidOperationException();
\r
160 return modifiedBefore;
\r
164 modifiedBefore = value;
\r
165 setModifiedBefore = true;
\r
169 public void ClearAll()
\r
171 setCategory = false;
\r
172 setCreatedAfter = false;
\r
173 setCreatedBefore = false;
\r
175 setMachineName = false;
\r
176 setModifiedAfter = false;
\r
177 setModifiedBefore = false;
\r
180 // To be called by the MessageQueue.GetPublicQueues(MessageQueueCriteria criteria) method
\r
181 internal bool Match(
\r
185 string machineName,
\r
188 if (setCategory && this.category != category)
\r
190 if (setCreatedAfter && created < createdAfter)
\r
192 if (setCreatedBefore && created > createdBefore)
\r
194 if (setLabel && this.label != label)
\r
196 if (setMachineName && this.machineName != machineName)
\r
198 if (setModifiedAfter && modified < modifiedAfter)
\r
200 if (setModifiedBefore && modified > modifiedBefore)
\r