2 // System.Web.Services.Description.OperationMessageCollection.cs
\r
5 // Tim Coleman (tim@timcoleman.com)
\r
7 // Copyright (C) Tim Coleman, 2002
\r
10 using System.Web.Services;
\r
12 namespace System.Web.Services.Description {
\r
13 public sealed class OperationMessageCollection : ServiceDescriptionBaseCollection {
\r
17 Operation operation;
\r
19 #endregion // Fields
\r
21 #region Constructors
\r
23 internal OperationMessageCollection (Operation operation)
\r
25 this.operation = operation;
\r
28 #endregion // Constructors
\r
32 public OperationFlow Flow {
\r
33 [MonoTODO ("Verify default return value.")]
\r
37 if (this[0] is OperationInput)
\r
38 return OperationFlow.OneWay;
\r
40 return OperationFlow.Notification;
\r
43 if (this[0] is OperationInput)
\r
44 return OperationFlow.RequestResponse;
\r
46 return OperationFlow.SolicitResponse;
\r
49 return OperationFlow.None; // .NET says default is SolicitResponse. Verify this.
\r
53 public OperationInput Input {
\r
55 foreach (object message in List)
\r
56 if (message is OperationInput)
\r
57 return (OperationInput) message;
\r
62 public OperationMessage this [int index] {
\r
63 get { return (OperationMessage) List[index]; }
\r
64 set { List[index] = value; }
\r
67 public OperationOutput Output {
\r
69 foreach (object message in List)
\r
70 if (message is OperationOutput)
\r
71 return (OperationOutput) message;
\r
76 #endregion // Properties
\r
80 public int Add (OperationMessage operationMessage)
\r
82 Insert (Count, operationMessage);
\r
86 public bool Contains (OperationMessage operationMessage)
\r
88 return List.Contains (operationMessage);
\r
91 public void CopyTo (OperationMessage[] array, int index)
\r
93 List.CopyTo (array, index);
\r
96 public int IndexOf (OperationMessage operationMessage)
\r
98 return List.IndexOf (operationMessage);
\r
101 public void Insert (int index, OperationMessage operationMessage)
\r
103 SetParent (operationMessage, operation);
\r
104 List.Insert (index, operationMessage);
\r
107 protected override void OnInsert (int index, object value)
\r
109 if (Count > 2 || value.GetType () == this [0].GetType ())
\r
110 throw new InvalidOperationException ("The operation object can only contain one input and one output message.");
\r
113 protected override void OnSet (int index, object oldValue, object newValue)
\r
115 if (oldValue.GetType () != newValue.GetType ())
\r
116 throw new InvalidOperationException ("The message types of the old and new value are not the same.");
\r
117 base.OnSet (index, oldValue, newValue);
\r
120 protected override void OnValidate (object value)
\r
123 throw new NullReferenceException ("The message object is a null reference.");
\r
124 if (!(value is OperationInput || value is OperationOutput))
\r
125 throw new ArgumentException ("The message object is not an input or an output message.");
\r
128 public void Remove (OperationMessage operationMessage)
\r
130 List.Remove (operationMessage);
\r
133 protected override void SetParent (object value, object parent)
\r
135 ((OperationMessage) value).SetParent ((Operation) parent);
\r
138 #endregion // Methods
\r