//\r
// Copyright (C) Tim Coleman, 2002\r
//\r
+
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
\r
using System.Web.Services;\r
\r
namespace System.Web.Services.Description {\r
public sealed class OperationMessageCollection : ServiceDescriptionBaseCollection {\r
\r
- #region Fields\r
-\r
- Operation operation;\r
-\r
- #endregion // Fields\r
-\r
#region Constructors\r
\r
internal OperationMessageCollection (Operation operation)\r
+ : base (operation)\r
{\r
- this.operation = operation; \r
}\r
\r
#endregion // Constructors\r
#region Properties\r
\r
public OperationFlow Flow {\r
- [MonoTODO]\r
- get { throw new NotImplementedException (); }\r
+ get { \r
+ switch (Count) {\r
+ case 1: \r
+ if (this[0] is OperationInput)\r
+ return OperationFlow.OneWay;\r
+ else\r
+ return OperationFlow.Notification;\r
+ case 2:\r
+ if (this[0] is OperationInput)\r
+ return OperationFlow.RequestResponse;\r
+ else\r
+ return OperationFlow.SolicitResponse;\r
+ }\r
+ return OperationFlow.None;\r
+ }\r
}\r
\r
public OperationInput Input {\r
- [MonoTODO]\r
- get { throw new NotImplementedException (); }\r
+ get { \r
+ foreach (object message in List)\r
+ if (message is OperationInput)\r
+ return (OperationInput) message;\r
+ return null;\r
+ }\r
}\r
\r
public OperationMessage this [int index] {\r
}\r
\r
public OperationOutput Output {\r
- [MonoTODO]\r
- set { throw new NotImplementedException (); }\r
+ get { \r
+ foreach (object message in List)\r
+ if (message is OperationOutput)\r
+ return (OperationOutput) message;\r
+ return null;\r
+ }\r
+ }\r
+\r
+ internal OperationFault Fault {\r
+ get { \r
+ foreach (object message in List)\r
+ if (message is OperationFault)\r
+ return (OperationFault) message;\r
+ return null;\r
+ }\r
}\r
\r
#endregion // Properties\r
\r
#region Methods\r
\r
+ protected override string GetKey (object value) \r
+ {\r
+ if (!(value is OperationMessage))\r
+ throw new InvalidCastException ();\r
+ return ((OperationMessage) value).Name;\r
+ }\r
+\r
public int Add (OperationMessage operationMessage) \r
{\r
Insert (Count, operationMessage);\r
\r
public void Insert (int index, OperationMessage operationMessage)\r
{\r
- SetParent (operationMessage, operation);\r
List.Insert (index, operationMessage);\r
}\r
\r
- [MonoTODO]\r
protected override void OnInsert (int index, object value)\r
{\r
- throw new NotImplementedException ();\r
+ if (Count == 0)\r
+ return;\r
+ \r
+ if (Count == 1 && value.GetType() != this[0].GetType())\r
+ return;\r
+\r
+ throw new InvalidOperationException ("The operation object can only contain one input and one output message.");\r
}\r
\r
- [MonoTODO]\r
protected override void OnSet (int index, object oldValue, object newValue)\r
{\r
- throw new NotImplementedException ();\r
+ if (oldValue.GetType () != newValue.GetType ())\r
+ throw new InvalidOperationException ("The message types of the old and new value are not the same.");\r
+ base.OnSet (index, oldValue, newValue);\r
}\r
\r
- [MonoTODO]\r
protected override void OnValidate (object value)\r
{\r
- throw new NotImplementedException ();\r
+ if (value == null)\r
+ throw new ArgumentException("The message object is a null reference.");\r
+ if (!(value is OperationInput || value is OperationOutput))\r
+ throw new ArgumentException ("The message object is not an input or an output message.");\r
}\r
\r
- public void Remove (Operation operationMessage)\r
+ public void Remove (OperationMessage operationMessage)\r
{\r
List.Remove (operationMessage);\r
}\r