* Binding.cs, Import.cs, Message.cs, MessageBinding.cs, MessagePart.cs,
[mono.git] / mcs / class / System.Web.Services / System.Web.Services.Description / OperationMessageCollection.cs
index 3e13e51f0f0e4db9f0d5a24ed032942d78e10ca5..117f968e5a8188e451cef193a654cc4796f0ab80 100644 (file)
@@ -12,17 +12,11 @@ using System.Web.Services;
 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
@@ -30,13 +24,30 @@ namespace System.Web.Services.Description {
                #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
@@ -45,8 +56,12 @@ namespace System.Web.Services.Description {
                }\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
                #endregion // Properties\r
@@ -76,29 +91,31 @@ namespace System.Web.Services.Description {
 \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 > 2 || (Count > 1 && value.GetType () == this [0].GetType ()))\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 NullReferenceException ("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