Files
mono/mcs/class/System.Web.Services/System.Web.Services.Description/OperationMessageCollection.cs
T
Lluis Sanchez 4a01835603 * DocumentableItem.cs MimeContentBinding.cs OperationMessage.cs
OperationMessageCollection.cs PortCollection.cs PortType.cs
	  PortTypeCollection.cs ServiceCollection.cs ServiceDescriptionCollection.cs
	  SoapBodyBinding.cs SoapOperationBinding.cs: Several fixes by Erik LeBel
	* ServiceDescriptionImporter.cs:
	* ServiceDescriptionSerializerBase.cs: regenerated after the changes in
	  the service description changes.
	* ServiceDescriptionReflector.cs: Fixed generation of message parts in
	  bare format.

svn path=/trunk/mcs/; revision=18079
2003-09-14 12:24:49 +00:00

143 lines
3.4 KiB
C#

//
// System.Web.Services.Description.OperationMessageCollection.cs
//
// Author:
// Tim Coleman ([email protected])
//
// Copyright (C) Tim Coleman, 2002
//
using System.Web.Services;
namespace System.Web.Services.Description {
public sealed class OperationMessageCollection : ServiceDescriptionBaseCollection {
#region Constructors
internal OperationMessageCollection (Operation operation)
: base (operation)
{
}
#endregion // Constructors
#region Properties
public OperationFlow Flow {
get {
switch (Count) {
case 1:
if (this[0] is OperationInput)
return OperationFlow.OneWay;
else
return OperationFlow.Notification;
case 2:
if (this[0] is OperationInput)
return OperationFlow.RequestResponse;
else
return OperationFlow.SolicitResponse;
}
return OperationFlow.None;
}
}
public OperationInput Input {
get {
foreach (object message in List)
if (message is OperationInput)
return (OperationInput) message;
return null;
}
}
public OperationMessage this [int index] {
get { return (OperationMessage) List[index]; }
set { List[index] = value; }
}
public OperationOutput Output {
get {
foreach (object message in List)
if (message is OperationOutput)
return (OperationOutput) message;
return null;
}
}
#endregion // Properties
#region Methods
protected override string GetKey (object value)
{
if (!(value is OperationMessage))
throw new InvalidCastException ();
return ((OperationMessage) value).Name;
}
public int Add (OperationMessage operationMessage)
{
Insert (Count, operationMessage);
return (Count - 1);
}
public bool Contains (OperationMessage operationMessage)
{
return List.Contains (operationMessage);
}
public void CopyTo (OperationMessage[] array, int index)
{
List.CopyTo (array, index);
}
public int IndexOf (OperationMessage operationMessage)
{
return List.IndexOf (operationMessage);
}
public void Insert (int index, OperationMessage operationMessage)
{
List.Insert (index, operationMessage);
}
protected override void OnInsert (int index, object value)
{
if (Count == 0)
return;
if (Count == 1 && value.GetType() != this[0].GetType())
return;
throw new InvalidOperationException ("The operation object can only contain one input and one output message.");
}
protected override void OnSet (int index, object oldValue, object newValue)
{
if (oldValue.GetType () != newValue.GetType ())
throw new InvalidOperationException ("The message types of the old and new value are not the same.");
base.OnSet (index, oldValue, newValue);
}
protected override void OnValidate (object value)
{
if (value == null)
throw new ArgumentException("The message object is a null reference.");
if (!(value is OperationInput || value is OperationOutput))
throw new ArgumentException ("The message object is not an input or an output message.");
}
public void Remove (OperationMessage operationMessage)
{
List.Remove (operationMessage);
}
protected override void SetParent (object value, object parent)
{
((OperationMessage) value).SetParent ((Operation) parent);
}
#endregion // Methods
}
}