OperationCollection 类

定义

表示 Operation 类的实例的集合。 此类不能被继承。

public ref class OperationCollection sealed : System::Web::Services::Description::ServiceDescriptionBaseCollection
public sealed class OperationCollection : System.Web.Services.Description.ServiceDescriptionBaseCollection
type OperationCollection = class
    inherit ServiceDescriptionBaseCollection
Public NotInheritable Class OperationCollection
Inherits ServiceDescriptionBaseCollection
继承

示例

下面的示例演示如何使用 类 OperationCollection 公开的属性和方法。

#using <System.dll>
#using <System.Xml.dll>
#using <System.Web.Services.dll>

using namespace System;
using namespace System::Web::Services;
using namespace System::Xml;
using namespace System::Web::Services::Description;
int main()
{
   try
   {
      // Read the 'MathService_Input_cs.wsdl' file.
      ServiceDescription^ myDescription = ServiceDescription::Read( "MathService_Input_cs.wsdl" );
      PortTypeCollection^ myPortTypeCollection = myDescription->PortTypes;

      // Get the 'OperationCollection' for 'SOAP' protocol.

      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 );

      if ( myOperationCollection->Contains( myOperation ) == true )
      {
         Console::WriteLine( "The index of the added 'myOperation' operation is : {0}", myOperationCollection->IndexOf( myOperation ) );
      }

      myOperationCollection->Remove( myOperation );
      
      // Insert the 'myOpearation' operation at the index '0'.
      myOperationCollection->Insert( 0, myOperation );
      Console::WriteLine( "The operation at index '0' is : {0}", myOperationCollection[ 0 ]->Name );

      array<Operation^>^myOperationArray = gcnew array<Operation^>(myOperationCollection->Count);
      myOperationCollection->CopyTo( myOperationArray, 0 );
      Console::WriteLine( "The operation(s) in the collection are :" );
      for ( int i = 0; i < myOperationCollection->Count; i++ )
      {
         Console::WriteLine( " {0}", myOperationArray[ i ]->Name );
      }

      myDescription->Write( "MathService_New_cs.wsdl" );
   }
   catch ( Exception^ e ) 
   {
      Console::WriteLine( "Exception caught!!!" );
      Console::WriteLine( "Source : {0}", e->Source );
      Console::WriteLine( "Message : {0}", e->Message );
   }
}
using System;
using System.Web.Services;
using System.Xml;
using System.Web.Services.Description;

class MyOperationCollectionSample
{
   public static void Main()
   {
      try
      {
         // Read the 'MathService_Input_cs.wsdl' file.
         ServiceDescription myDescription =
                     ServiceDescription.Read("MathService_Input_cs.wsdl");
         PortTypeCollection myPortTypeCollection =myDescription.PortTypes;
         // Get the 'OperationCollection' for 'SOAP' protocol.
         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);

         if(myOperationCollection.Contains(myOperation) == true)
         {
            Console.WriteLine("The index of the added 'myOperation' " +
                              "operation is : " +
                              myOperationCollection.IndexOf(myOperation));
         }

         myOperationCollection.Remove(myOperation);
         // Insert the 'myOpearation' operation at the index '0'.
         myOperationCollection.Insert(0, myOperation);
         Console.WriteLine("The operation at index '0' is : " +
                           myOperationCollection[0].Name);

         Operation[] myOperationArray = new Operation[
                                             myOperationCollection.Count];
         myOperationCollection.CopyTo(myOperationArray, 0);
         Console.WriteLine("The operation(s) in the collection are :");
         for(int i = 0; i < myOperationCollection.Count; i++)
         {
            Console.WriteLine(" " + myOperationArray[i].Name);
         }

         myDescription.Write("MathService_New_cs.wsdl");
      }
      catch(Exception e)
      {
         Console.WriteLine("Exception caught!!!");
         Console.WriteLine("Source : " + e.Source);
         Console.WriteLine("Message : " + e.Message);
      }
   }
}
Option Strict On
Imports System.Web.Services
Imports System.Xml
Imports System.Web.Services.Description

Class MyOperationCollectionSample
   Public Shared Sub Main()
      Try
         ' Read the 'MathService_Input_vb.wsdl' file.
         Dim myDescription As ServiceDescription = _
                        ServiceDescription.Read("MathService_Input_vb.wsdl")
         Dim myPortTypeCollection As PortTypeCollection = _
                                                   myDescription.PortTypes
         ' Get the 'OperationCollection' for 'SOAP' protocol.
         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)

         If myOperationCollection.Contains(myOperation) = True Then
            Console.WriteLine("The index of the added 'myOperation' " + _
                     "operation is : " + _
                     myOperationCollection.IndexOf(myOperation).ToString)
         End If

         myOperationCollection.Remove(myOperation)
         ' Insert the 'myOpearation' operation at the index '0'.
         myOperationCollection.Insert(0, myOperation)
         Console.WriteLine("The operation at index '0' is : " + _
                           myOperationCollection.Item(0).Name)

         Dim myOperationArray(myOperationCollection.Count) As Operation
         myOperationCollection.CopyTo(myOperationArray, 0)
         Console.WriteLine("The operation(s) in the collection are :")
         Dim i As Integer
         For i = 0 To myOperationCollection.Count - 1
            Console.WriteLine(" " + myOperationArray(i).Name)
         Next i

         myDescription.Write("MathService_New_vb.wsdl")
      Catch e As Exception
         Console.WriteLine("Exception caught!!!")
         Console.WriteLine("Source : " + e.Source)
         Console.WriteLine("Message : " + e.Message)
      End Try
   End Sub
End Class

注解

Operation对应于由 元素括<portType>起来的 WSDL) <operation> 元素 (Web 服务描述语言。 有关 WSDL 的更多信息,请参阅 WSDL 规范。

属性

Capacity

获取或设置 CollectionBase 可包含的元素数。

(继承自 CollectionBase)
Count

获取 CollectionBase 实例中包含的元素数。 不能重写此属性。

(继承自 CollectionBase)
InnerList

获取一个 ArrayList,它包含 CollectionBase 实例中元素的列表。

(继承自 CollectionBase)
Item[Int32]

获取或设置位于指定的从零开始的索引处的 Operation 的值。

List

获取一个 IList,它包含 CollectionBase 实例中元素的列表。

(继承自 CollectionBase)
Table

获取实现 ServiceDescriptionBaseCollection 中键和值的关联的接口。

(继承自 ServiceDescriptionBaseCollection)

方法

Add(Operation)

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

Clear()

CollectionBase 实例移除所有对象。 不能重写此方法。

(继承自 CollectionBase)
Contains(Operation)

返回一个值,该值指示指定的 Operation 是否是 OperationCollection 的成员。

CopyTo(Operation[], Int32)

将整个 OperationCollection 复制到兼容的、Operation 类型的一维数组(从目标数组的指定的从零开始的索引处开始复制)。

Equals(Object)

确定指定对象是否等于当前对象。

(继承自 Object)
GetEnumerator()

返回循环访问 CollectionBase 实例的枚举器。

(继承自 CollectionBase)
GetHashCode()

作为默认哈希函数。

(继承自 Object)
GetKey(Object)

返回与通过引用传递的值关联的键的名称。

(继承自 ServiceDescriptionBaseCollection)
GetType()

获取当前实例的 Type

(继承自 Object)
IndexOf(Operation)

搜索指定的 Operation,并返回集合中第一个匹配项的索引(从零开始)。

Insert(Int32, Operation)

将指定的 Operation 添加到 OperationCollection 中指定的从零开始的索引处。

MemberwiseClone()

创建当前 Object 的浅表副本。

(继承自 Object)
OnClear()

清除 ServiceDescriptionBaseCollection 实例的内容。

(继承自 ServiceDescriptionBaseCollection)
OnClearComplete()

在清除 CollectionBase 实例的内容之后执行其他自定义进程。

(继承自 CollectionBase)
OnInsert(Int32, Object)

在向 CollectionBase 实例中插入新元素之前执行其他自定义进程。

(继承自 CollectionBase)
OnInsertComplete(Int32, Object)

将新元素插入 ServiceDescriptionBaseCollection 后,执行附加的自定义进程。

(继承自 ServiceDescriptionBaseCollection)
OnRemove(Int32, Object)

ServiceDescriptionBaseCollection 中移除一个元素。

(继承自 ServiceDescriptionBaseCollection)
OnRemoveComplete(Int32, Object)

在从 CollectionBase 实例中移除元素之后执行其他自定义进程。

(继承自 CollectionBase)
OnSet(Int32, Object, Object)

ServiceDescriptionBaseCollection 中的一个值替换另一个值。

(继承自 ServiceDescriptionBaseCollection)
OnSetComplete(Int32, Object, Object)

当在 CollectionBase 实例中设置值后执行其他自定义进程。

(继承自 CollectionBase)
OnValidate(Object)

当验证值时执行其他自定义进程。

(继承自 CollectionBase)
Remove(Operation)

Operation 中移除指定的 OperationCollection 的第一个匹配项。

RemoveAt(Int32)

移除 CollectionBase 实例的指定索引处的元素。 此方法不可重写。

(继承自 CollectionBase)
SetParent(Object, Object)

设置 ServiceDescriptionBaseCollection 实例的父对象。

(继承自 ServiceDescriptionBaseCollection)
ToString()

返回表示当前对象的字符串。

(继承自 Object)

显式接口实现

ICollection.CopyTo(Array, Int32)

从目标数组的指定索引处开始将整个 CollectionBase 复制到兼容的一维 Array

(继承自 CollectionBase)
ICollection.IsSynchronized

获取一个值,该值指示是否同步对 CollectionBase 的访问(线程安全)。

(继承自 CollectionBase)
ICollection.SyncRoot

获取可用于同步对 CollectionBase 的访问的对象。

(继承自 CollectionBase)
IList.Add(Object)

将对象添加到 CollectionBase 的结尾处。

(继承自 CollectionBase)
IList.Contains(Object)

确定 CollectionBase 是否包含特定元素。

(继承自 CollectionBase)
IList.IndexOf(Object)

搜索指定的 Object,并返回整个 CollectionBase 中第一个匹配项的从零开始的索引。

(继承自 CollectionBase)
IList.Insert(Int32, Object)

将元素插入 CollectionBase 的指定索引处。

(继承自 CollectionBase)
IList.IsFixedSize

获取一个值,该值指示 CollectionBase 是否具有固定大小。

(继承自 CollectionBase)
IList.IsReadOnly

获取一个值,该值指示 CollectionBase 是否为只读。

(继承自 CollectionBase)
IList.Item[Int32]

获取或设置指定索引处的元素。

(继承自 CollectionBase)
IList.Remove(Object)

CollectionBase 中移除特定对象的第一个匹配项。

(继承自 CollectionBase)

扩展方法

Cast<TResult>(IEnumerable)

IEnumerable 的元素强制转换为指定的类型。

OfType<TResult>(IEnumerable)

根据指定类型筛选 IEnumerable 的元素。

AsParallel(IEnumerable)

启用查询的并行化。

AsQueryable(IEnumerable)

IEnumerable 转换为 IQueryable

适用于