OperationMessageCollection.Add(OperationMessage) 方法

定义

将指定的 OperationMessage 添加到 OperationMessageCollection 的结尾。

public:
 int Add(System::Web::Services::Description::OperationMessage ^ operationMessage);
public int Add (System.Web.Services.Description.OperationMessage operationMessage);
member this.Add : System.Web.Services.Description.OperationMessage -> int
Public Function Add (operationMessage As OperationMessage) As Integer

参数

operationMessage
OperationMessage

要添加到集合中的 OperationMessage

返回

Int32

添加了 operationMessage 参数的位置的从零开始的索引。

示例

// Get the operation message for the Add operation.
OperationMessage^ myOperationMessage = myOperationMessageCollection[ 0 ];
OperationMessage^ myInputOperationMessage = dynamic_cast<OperationMessage^>(gcnew OperationInput);
XmlQualifiedName^ myXmlQualifiedName = gcnew XmlQualifiedName( "AddSoapIn",myDescription->TargetNamespace );
myInputOperationMessage->Message = myXmlQualifiedName;

array<OperationMessage^>^myCollection = gcnew array<OperationMessage^>(myOperationMessageCollection->Count);
myOperationMessageCollection->CopyTo( myCollection, 0 );
Console::WriteLine( "Operation name(s) :" );
for ( int i = 0; i < myCollection->Length; i++ )
{
   Console::WriteLine( " {0}", myCollection[ i ]->Operation->Name );
}

// Add the OperationMessage to the collection.
myOperationMessageCollection->Add( myInputOperationMessage );
// Get the operation message for the Add operation.
OperationMessage myOperationMessage =
   myOperationMessageCollection[0];
OperationMessage myInputOperationMessage =
   (OperationMessage) new OperationInput();
XmlQualifiedName myXmlQualifiedName = new XmlQualifiedName(
   "AddSoapIn", myDescription.TargetNamespace);
myInputOperationMessage.Message = myXmlQualifiedName;

OperationMessage[] myCollection =
   new OperationMessage[myOperationMessageCollection.Count];
myOperationMessageCollection.CopyTo(myCollection, 0);
Console.WriteLine("Operation name(s) :");
for (int i = 0; i < myCollection.Length ; i++)
{
   Console.WriteLine(" " + myCollection[i].Operation.Name);
}

// Add the OperationMessage to the collection.
myOperationMessageCollection.Add(myInputOperationMessage);
' Get the operation message for the Add operation.
Dim myOperationMessage As OperationMessage = _
   myOperationMessageCollection.Item(0)
Dim myInputOperationMessage As OperationMessage = _
   CType(New OperationInput(), OperationMessage)
Dim myXmlQualifiedName As _
   New XmlQualifiedName("AddSoapIn", myDescription.TargetNamespace)
myInputOperationMessage.Message = myXmlQualifiedName

Dim myCollection(myOperationMessageCollection.Count -1 ) _
   As OperationMessage
myOperationMessageCollection.CopyTo(myCollection, 0)
Console.WriteLine("Operation name(s) :")
Dim i As Integer
For i = 0 To myCollection.Length - 1
   Console.WriteLine(" " & myCollection(i).Operation.Name)
Next i

' Add the OperationMessage to the collection.
myOperationMessageCollection.Add(myInputOperationMessage)

适用于