OperationCollection.Add(Operation) 方法

定义

将指定的 Operation 添加到 OperationCollection 的结尾。

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

参数

operation
Operation

要添加到集合中的 Operation

返回

Int32

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

示例

下面的示例演示 Add 方法的用法。

OperationCollection^ myOperationCollection = myPortTypeCollection[ 0 ]->Operations;
Operation^ myOperation = gcnew Operation;
myOperation->Name = "Add";
OperationMessage^ myOperationMessageInput = (OperationMessage^)(gcnew OperationInput);
myOperationMessageInput->Message = gcnew XmlQualifiedName( "AddSoapIn",myDescription->TargetNamespace );
OperationMessage^ myOperationMessageOutput = (OperationMessage^)(gcnew OperationOutput);
myOperationMessageOutput->Message = gcnew XmlQualifiedName( "AddSoapOut",myDescription->TargetNamespace );
myOperation->Messages->Add( myOperationMessageInput );
myOperation->Messages->Add( myOperationMessageOutput );
myOperationCollection->Add( myOperation );
OperationCollection myOperationCollection =
                              myPortTypeCollection[0].Operations;
Operation myOperation = new Operation();
myOperation.Name = "Add";
OperationMessage myOperationMessageInput =
                         (OperationMessage) new OperationInput();
myOperationMessageInput.Message = new XmlQualifiedName
                     ("AddSoapIn",myDescription.TargetNamespace);
OperationMessage myOperationMessageOutput =
                        (OperationMessage) new OperationOutput();
myOperationMessageOutput.Message = new XmlQualifiedName(
                     "AddSoapOut",myDescription.TargetNamespace);
myOperation.Messages.Add(myOperationMessageInput);
myOperation.Messages.Add(myOperationMessageOutput);
myOperationCollection.Add(myOperation);
Dim myOperationCollection As OperationCollection = _
                                myPortTypeCollection(0).Operations
Dim myOperation As New Operation()
myOperation.Name = "Add"
Dim myOperationMessageInput As OperationMessage = _
                     CType(New OperationInput(), OperationMessage)
myOperationMessageInput.Message = New XmlQualifiedName _
                     ("AddSoapIn", myDescription.TargetNamespace)
Dim myOperationMessageOutput As OperationMessage = _
                     CType(New OperationOutput(), OperationMessage)
myOperationMessageOutput.Message = New XmlQualifiedName _
                     ("AddSoapOut", myDescription.TargetNamespace)
myOperation.Messages.Add(myOperationMessageInput)
myOperation.Messages.Add(myOperationMessageOutput)
myOperationCollection.Add(myOperation)

适用于