**** Merged from MCS ****
[mono-project.git] / mcs / class / System.Messaging / System.Messaging / MessageQueue.cs
blobaf7f50795134f95e775bd9e7093708d439f4ba3d
1 //
2 // System.Messaging
3 //
4 // Authors:
5 // Peter Van Isacker (sclytrack@planetinternet.be)
6 // Rafael Teixeira (rafaelteixeirabr@hotmail.com)
7 //
8 // (C) 2003 Peter Van Isacker
9 //
12 // Permission is hereby granted, free of charge, to any person obtaining
13 // a copy of this software and associated documentation files (the
14 // "Software"), to deal in the Software without restriction, including
15 // without limitation the rights to use, copy, modify, merge, publish,
16 // distribute, sublicense, and/or sell copies of the Software, and to
17 // permit persons to whom the Software is furnished to do so, subject to
18 // the following conditions:
19 //
20 // The above copyright notice and this permission notice shall be
21 // included in all copies or substantial portions of the Software.
22 //
23 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
27 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
28 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
29 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
32 using System;
33 using System.Collections;
34 using System.ComponentModel;
35 using System.Drawing;
36 using System.Messaging.Design;
38 namespace System.Messaging
40 [TypeConverter (typeof(MessageQueueConverter))]
41 [Editor ("System.Messaging.Design.QueuePathEditor", "System.Drawing.Design.UITypeEditor, " + Consts.AssemblySystem_Drawing)]
42 [Designer ("Microsoft.VisualStudio.Install.MessageQueueInstallableComponentDesigner, " + Consts.AssemblyMicrosoft_VisualStudio)]
43 [InstallerType (typeof(MessageQueueInstaller))]
44 [DefaultEvent ("ReceiveCompleted")]
45 public class MessageQueue : Component, IEnumerable
47 #region Fields
49 public static readonly long InfiniteQueueSize;
50 public static readonly TimeSpan InfiniteTimeout;
52 private bool isPrivate = false;
53 private string queueName;
54 private string machineName;
57 #endregion //Fields
60 #region Constructor
62 [MonoTODO]
63 public MessageQueue ()
65 throw new NotImplementedException ();
68 [MonoTODO]
69 public MessageQueue (string path) {
70 this.Path = path;
71 this.isPrivate = false;
74 [MonoTODO]
75 private MessageQueue (string queueName, string machineName, bool isPrivate)
77 this.queueName = queueName;
78 this.machineName = machineName;
79 this.isPrivate = isPrivate;
82 [MonoTODO]
83 public MessageQueue (string path, bool sharedModeDenyReceive)
85 throw new NotImplementedException ();
88 #endregion //Constructor
90 #region Properties
92 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
93 [MessagingDescription ("MQ_Authenticate")]
94 public bool Authenticate {
95 [MonoTODO]
96 get {
97 throw new NotImplementedException ();
99 [MonoTODO]
100 set {
101 throw new NotImplementedException ();
105 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
106 [MessagingDescription ("MQ_BasePriority")]
107 public short BasePriority {
108 [MonoTODO]
109 get {
110 throw new NotImplementedException ();
112 [MonoTODO]
113 set {
114 throw new NotImplementedException ();
118 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
119 [Browsable (false)]
120 [MessagingDescription ("MQ_CanRead")]
121 public bool CanRead {
122 [MonoTODO]
123 get {
124 throw new NotImplementedException ();
128 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
129 [Browsable (false)]
130 [MessagingDescription ("MQ_CanWrite")]
131 public bool CanWrite {
132 [MonoTODO]
133 get {
134 throw new NotImplementedException ();
138 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
139 [MessagingDescription ("MQ_Category")]
140 public Guid Category {
141 [MonoTODO]
142 get {
143 throw new NotImplementedException ();
145 [MonoTODO]
146 set {
147 throw new NotImplementedException ();
151 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
152 [MessagingDescription ("MQ_CreateTime")]
153 public DateTime CreateTime {
154 [MonoTODO]
155 get {
156 throw new NotImplementedException ();
160 [DesignerSerializationVisibility (DesignerSerializationVisibility.Content)]
161 [Browsable (false)]
162 [MessagingDescription ("MQ_DefaultPropertiesToSend")]
163 public DefaultPropertiesToSend DefaultPropertiesToSend {
164 [MonoTODO]
165 get {
166 throw new NotImplementedException ();
168 [MonoTODO]
169 set {
170 throw new NotImplementedException ();
174 [Browsable (false)]
175 [DefaultValue (false)]
176 [MessagingDescription ("MQ_DenySharedReceive")]
177 public bool DenySharedReceive {
178 [MonoTODO]
179 get {
180 throw new NotImplementedException ();
182 [MonoTODO]
183 set {
184 throw new NotImplementedException ();
188 [Browsable (false)]
189 public static bool EnableConnectionCache {
190 [MonoTODO]
191 get {
192 throw new NotImplementedException ();
194 [MonoTODO]
195 set {
196 throw new NotImplementedException ();
200 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
201 [MessagingDescription ("MQ_EncryptionRequired")]
202 public EncryptionRequired EncryptionRequired {
203 [MonoTODO]
204 get {
205 throw new NotImplementedException ();
207 [MonoTODO]
208 set {
209 throw new NotImplementedException ();
213 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
214 [MessagingDescription ("MQ_FormatName")]
215 public string FormatName {
216 [MonoTODO]
217 get {
218 throw new NotImplementedException ();
222 [Browsable (false)]
223 [DefaultValue (null)]
224 [TypeConverter (typeof(MessageFormatterConverter))]
225 [MessagingDescription ("MQ_Formatter")]
226 public IMessageFormatter Formatter {
227 [MonoTODO]
228 get {
229 throw new NotImplementedException ();
231 [MonoTODO]
232 set {
233 throw new NotImplementedException ();
237 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
238 [MessagingDescription ("MQ_GuidId")]
239 public Guid Id {
240 [MonoTODO]
241 get {
242 throw new NotImplementedException ();
246 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
247 [MessagingDescription ("MQ_Label")]
248 public string Label {
249 [MonoTODO]
250 get {
251 throw new NotImplementedException ();
253 [MonoTODO]
254 set {
255 throw new NotImplementedException ();
259 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
260 [MessagingDescription ("MQ_LastModifyTime")]
261 public DateTime LastModifyTime {
262 [MonoTODO]
263 get {
264 throw new NotImplementedException ();
268 [Browsable (false)]
269 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
270 [MessagingDescription ("MQ_MachineName")]
271 public string MachineName {
272 get {
273 return machineName;
275 set {
276 machineName = value;
280 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
281 [TypeConverter (typeof(SizeConverter))]
282 [MessagingDescription ("MQ_MaximumJournalSize")]
283 public long MaximumJournalSize {
284 [MonoTODO]
285 get {
286 throw new NotImplementedException ();
288 [MonoTODO]
289 set {
290 throw new NotImplementedException ();
294 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
295 [TypeConverter (typeof(SizeConverter))]
296 [MessagingDescription ("MQ_MaximumQueueSize")]
297 public long MaximumQueueSize {
298 [MonoTODO]
299 get {
300 throw new NotImplementedException ();
302 [MonoTODO]
303 set {
304 throw new NotImplementedException ();
308 [Browsable (false)]
309 [DesignerSerializationVisibility (DesignerSerializationVisibility.Content)]
310 [MessagingDescription ("MQ_MessageReadPropertyFilter")]
311 public MessagePropertyFilter MessageReadPropertyFilter {
312 [MonoTODO]
313 get {
314 throw new NotImplementedException ();
316 [MonoTODO]
317 set {
318 throw new NotImplementedException ();
322 [RecommendedAsConfigurable (true)]
323 [Editor ("System.Messaging.Design.QueuePathEditor", "System.Drawing.Design.UITypeEditor, " + Consts.AssemblySystem_Drawing)]
324 [Browsable (false)]
325 [DefaultValue ("")]
326 [TypeConverter ("System.Diagnostics.Design.StringValueConverter, " + Consts.AssemblySystem_Design)]
327 [MessagingDescription ("MQ_Path")]
328 public string Path {
329 get {
330 return machineName + ":" + queueName;
332 [MonoTODO ("split input")]
333 set {
334 throw new NotImplementedException ();
338 [Browsable (false)]
339 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
340 [MessagingDescription ("MQ_QueueName")]
341 public string QueueName {
342 get {
343 return queueName;
345 set {
346 queueName = value;
350 [Browsable (false)]
351 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
352 [MessagingDescription ("MQ_ReadHandle")]
353 public IntPtr ReadHandle {
354 [MonoTODO]
355 get {
356 throw new NotImplementedException ();
360 [Browsable (false)]
361 [DefaultValue (null)]
362 [MessagingDescription ("MQ_SynchronizingObject")]
363 public ISynchronizeInvoke SynchronizingObject {
364 [MonoTODO]
365 get {
366 throw new NotImplementedException ();
368 [MonoTODO]
369 set {
370 throw new NotImplementedException ();
374 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
375 [MessagingDescription ("MQ_Transactional")]
376 public bool Transactional {
377 [MonoTODO]
378 get {
379 throw new NotImplementedException ();
383 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
384 [MessagingDescription ("MQ_WriteHandle")]
385 public bool UseJournalQueue {
386 [MonoTODO]
387 get {
388 throw new NotImplementedException ();
390 [MonoTODO]
391 set {
392 throw new NotImplementedException ();
396 [Browsable (false)]
397 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
398 [MessagingDescription ("MQ_WriteHandle")]
399 public IntPtr WriteHandle {
400 [MonoTODO]
401 get {
402 throw new NotImplementedException ();
406 #endregion //Properties
408 #region Methods
410 [MonoTODO]
411 public IAsyncResult BeginPeek ()
413 throw new NotImplementedException ();
415 [MonoTODO]
416 public IAsyncResult BeginPeek (TimeSpan timeout)
418 throw new NotImplementedException ();
420 [MonoTODO]
421 public IAsyncResult BeginPeek (TimeSpan timeout, object stateObject)
423 throw new NotImplementedException ();
425 [MonoTODO]
426 public IAsyncResult BeginPeek (TimeSpan timeout,
427 object stateObject,
428 AsyncCallback callback)
430 throw new NotImplementedException ();
432 [MonoTODO]
433 public IAsyncResult BeginReceive ()
435 throw new NotImplementedException ();
437 [MonoTODO]
438 public IAsyncResult BeginReceive (TimeSpan timeout)
440 throw new NotImplementedException ();
442 [MonoTODO]
443 public IAsyncResult BeginReceive (TimeSpan timeout, object stateObject)
445 throw new NotImplementedException ();
447 [MonoTODO]
448 public IAsyncResult BeginReceive (TimeSpan timeout, object stateObject, AsyncCallback callback)
450 throw new NotImplementedException ();
452 [MonoTODO]
453 public static void ClearConnectionCache ()
455 throw new NotImplementedException ();
457 [MonoTODO]
458 public void Close ()
460 throw new NotImplementedException ();
462 [MonoTODO]
463 public static MessageQueue Create (string path)
465 throw new NotImplementedException ();
467 [MonoTODO]
468 public static MessageQueue Create (string path, bool transactional)
470 throw new NotImplementedException ();
472 [MonoTODO]
473 public static void Delete (string path)
475 throw new NotImplementedException ();
477 [MonoTODO]
478 public Message EndPeek (IAsyncResult asyncResult)
480 throw new NotImplementedException ();
482 [MonoTODO]
483 public Message EndReceive (IAsyncResult asyncResult)
485 throw new NotImplementedException ();
487 [MonoTODO]
488 public static bool Exists (string path)
490 throw new NotImplementedException ();
492 [MonoTODO]
493 public Message[] GetAllMessages ()
495 throw new NotImplementedException ();
497 [MonoTODO]
498 public IEnumerator GetEnumerator ()
500 throw new NotImplementedException ();
502 [MonoTODO]
503 public static Guid GetMachineId (string machineName)
505 throw new NotImplementedException ();
507 [MonoTODO]
508 public MessageEnumerator GetMessageEnumerator ()
510 throw new NotImplementedException ();
513 private static ArrayList currentQueueList;
515 static MessageQueue ()
517 currentQueueList = new ArrayList ();
518 // for testing purposes
519 currentQueueList.Add (new MessageQueue (@"localhost:\public\TestQueue"));
520 currentQueueList.Add (new MessageQueue (@"\private\AnotherTestQueue", "localhost", true));
523 public static MessageQueueEnumerator GetMessageQueueEnumerator ()
525 return new MessageQueueEnumerator (currentQueueList);
528 private static ArrayList filteredQueueList (MessageQueueCriteria criteria)
530 ArrayList list = new ArrayList ();
531 foreach (MessageQueue queue in currentQueueList)
532 if (criteria.Match (queue.Id, queue.CreateTime, queue.Label, queue.MachineName, queue.LastModifyTime))
533 list.Add (queue);
534 return list;
537 public static MessageQueueEnumerator GetMessageQueueEnumerator (MessageQueueCriteria criteria)
539 return new MessageQueueEnumerator (filteredQueueList (criteria));
542 public static MessageQueue[] GetPrivateQueuesByMachine (string machineName)
544 if (machineName == null || machineName.Length == 0)
545 throw new ArgumentException ();
546 ArrayList list = new ArrayList ();
547 foreach (MessageQueue queue in currentQueueList)
548 if (queue.machineName == machineName && queue.isPrivate)
549 list.Add (queue);
550 return (MessageQueue[]) list.ToArray (typeof(MessageQueue));
553 [MonoTODO]
554 public static MessageQueue[] GetPublicQueues ()
556 throw new NotImplementedException ();
558 [MonoTODO]
559 public static MessageQueue[] GetPublicQueues (MessageQueueCriteria criteria)
561 throw new NotImplementedException ();
563 [MonoTODO]
564 public static MessageQueue[] GetPublicQueuesByCategory (Guid category)
566 throw new NotImplementedException ();
568 [MonoTODO]
569 public static MessageQueue[] GetPublicQueuesByLabel (string label)
571 throw new NotImplementedException ();
573 [MonoTODO]
574 public static MessageQueue[] GetPublicQueuesByMachine (string machineName)
576 throw new NotImplementedException ();
578 [MonoTODO]
579 public Message Peek ()
581 throw new NotImplementedException ();
583 [MonoTODO]
584 public Message Peek (TimeSpan timeout)
586 throw new NotImplementedException ();
588 [MonoTODO]
589 public Message PeekByCorrelationId (string correlationId)
591 throw new NotImplementedException ();
593 [MonoTODO]
594 public Message PeekByCorrelationId (string correlationId, TimeSpan timeout)
596 throw new NotImplementedException ();
598 [MonoTODO]
599 public Message PeekById (string id)
601 throw new NotImplementedException ();
603 [MonoTODO]
604 public Message PeekById (string id, TimeSpan timeout)
606 throw new NotImplementedException ();
608 [MonoTODO]
609 public void Purge ()
611 throw new NotImplementedException ();
613 [MonoTODO]
614 public Message Receive ()
616 throw new NotImplementedException ();
618 [MonoTODO]
619 public Message Receive (MessageQueueTransaction transaction)
621 throw new NotImplementedException ();
623 [MonoTODO]
624 public Message Receive (MessageQueueTransactionType transactionType)
626 throw new NotImplementedException ();
628 [MonoTODO]
629 public Message Receive (TimeSpan timeout)
631 throw new NotImplementedException ();
633 [MonoTODO]
634 public Message Receive (TimeSpan timeout, MessageQueueTransaction transaction)
636 throw new NotImplementedException ();
638 [MonoTODO]
639 public Message Receive (TimeSpan timeout, MessageQueueTransactionType transactionType)
641 throw new NotImplementedException ();
643 [MonoTODO]
644 public Message ReceiveByCorrelationId (string correlationId)
646 throw new NotImplementedException ();
648 [MonoTODO]
649 public Message ReceiveByCorrelationId (string correlationId, MessageQueueTransaction transaction)
651 throw new NotImplementedException ();
653 [MonoTODO]
654 public Message ReceiveByCorrelationId (string correlationId, MessageQueueTransactionType transactionType)
656 throw new NotImplementedException ();
658 [MonoTODO]
659 public Message ReceiveByCorrelationId (string correlationId, TimeSpan timeout)
661 throw new NotImplementedException ();
663 [MonoTODO]
664 public Message ReceiveByCorrelationId (string correlationId, TimeSpan timeout, MessageQueueTransaction transaction)
666 throw new NotImplementedException ();
668 [MonoTODO]
669 public Message ReceiveByCorrelationId (string correlationId, TimeSpan timeout, MessageQueueTransactionType transactionType)
671 throw new NotImplementedException ();
673 [MonoTODO]
674 public Message ReceiveById (string id)
676 throw new NotImplementedException ();
678 [MonoTODO]
679 public Message ReceiveById (string id, MessageQueueTransaction transaction)
681 throw new NotImplementedException ();
683 [MonoTODO]
684 public Message ReceiveById (string id, MessageQueueTransactionType transactionType)
686 throw new NotImplementedException ();
688 [MonoTODO]
689 public Message ReceiveById (string id, TimeSpan timeout)
691 throw new NotImplementedException ();
693 [MonoTODO]
694 public Message ReceiveById (string id, TimeSpan timeout, MessageQueueTransaction transaction)
696 throw new NotImplementedException ();
698 [MonoTODO]
699 public Message ReceiveById (string id, TimeSpan timeout, MessageQueueTransactionType transactionType)
701 throw new NotImplementedException ();
703 [MonoTODO]
704 public void Refresh ()
706 throw new NotImplementedException ();
708 [MonoTODO]
709 public void ResetPermissions ()
711 throw new NotImplementedException ();
713 [MonoTODO]
714 public void Send (object obj)
716 throw new NotImplementedException ();
718 [MonoTODO]
719 public void Send (object obj, MessageQueueTransaction transaction)
721 throw new NotImplementedException ();
723 [MonoTODO]
724 public void Send (object obj, MessageQueueTransactionType transactionType)
726 throw new NotImplementedException ();
728 [MonoTODO]
729 public void Send (object obj, string label)
731 throw new NotImplementedException ();
733 [MonoTODO]
734 public void Send (object obj, string label, MessageQueueTransaction transaction)
736 throw new NotImplementedException ();
738 [MonoTODO]
739 public void Send (object obj, string label, MessageQueueTransactionType transactionType)
741 throw new NotImplementedException ();
743 [MonoTODO]
744 public void SetPermissions (AccessControlList dacl)
746 throw new NotImplementedException ();
748 [MonoTODO]
749 public void SetPermissions (MessageQueueAccessControlEntry ace)
751 throw new NotImplementedException ();
753 [MonoTODO]
754 public void SetPermissions (string user, MessageQueueAccessRights rights)
756 throw new NotImplementedException ();
758 [MonoTODO]
759 public void SetPermissions (string user, MessageQueueAccessRights rights, AccessControlEntryType entryType)
761 throw new NotImplementedException ();
763 [MonoTODO]
764 protected override void Dispose (bool disposing)
766 throw new NotImplementedException ();
769 #endregion //Methods
771 //TODO: Use these events.
773 [MessagingDescription ("MQ_PeekCompleted")]
774 public event PeekCompletedEventHandler PeekCompleted;
776 [MessagingDescription ("MQ_ReceiveCompleted")]
777 public event ReceiveCompletedEventHandler ReceiveCompleted;