共用方式為


OperationMessageCollection 類別

定義

代表與 XML Web 服務相關的一組 OperationInputOperationOutput 訊息。 無法繼承這個類別。

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

範例

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

using namespace System;
using namespace System::Xml;
using namespace System::Web::Services;
using namespace System::Web::Services::Description;

// Displays the properties of the OperationMessageCollection.
void DisplayFlowInputOutput( OperationMessageCollection^ myOperationMessageCollection, String^ myOperation )
{
   Console::WriteLine( "After {0}:", myOperation );
   Console::WriteLine( "Flow : {0}", myOperationMessageCollection->Flow );
   Console::WriteLine( "The first occurrence of operation Input in the collection {0}", myOperationMessageCollection->Input );
   Console::WriteLine( "The first occurrence of operation Output in the collection {0}", myOperationMessageCollection->Output );
   Console::WriteLine();
}

int main()
{
   try
   {
      ServiceDescription^ myDescription = ServiceDescription::Read( "MathService_input_cs.wsdl" );
      PortTypeCollection^ myPortTypeCollection = myDescription->PortTypes;

      // Get the OperationCollection for the SOAP protocol.
      OperationCollection^ myOperationCollection = myPortTypeCollection[ 0 ]->Operations;

      // Get the OperationMessageCollection for the Add operation.
      OperationMessageCollection^ myOperationMessageCollection = myOperationCollection[ 0 ]->Messages;

      // Display the Flow, Input, and Output properties.
      DisplayFlowInputOutput( myOperationMessageCollection, "Start" );

      // 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 );
      
      DisplayFlowInputOutput( myOperationMessageCollection, "Add" );
      
      if ( myOperationMessageCollection->Contains( myOperationMessage ))
      {
         int myIndex = myOperationMessageCollection->IndexOf( myOperationMessage );
         Console::WriteLine( " The index of the Add operation message in the collection is : {0}", myIndex );
      }

      myOperationMessageCollection->Remove( myInputOperationMessage );

      // Display Flow, Input, and Output after removing.
      DisplayFlowInputOutput( myOperationMessageCollection, "Remove" );

      // Insert the message at index 0 in the collection.
      myOperationMessageCollection->Insert( 0, myInputOperationMessage );

      // Display Flow, Input, and Output after inserting.
      DisplayFlowInputOutput( myOperationMessageCollection, "Insert" );

      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.Xml;
using System.Web.Services;
using System.Web.Services.Description;

class MyOperationMessageCollectionSample
{
   static void Main()
   {
      try
      {
         ServiceDescription myDescription =
            ServiceDescription.Read("MathService_input_cs.wsdl");
         PortTypeCollection myPortTypeCollection  =
            myDescription.PortTypes;

         // Get the OperationCollection for the SOAP protocol.
         OperationCollection myOperationCollection =
            myPortTypeCollection[0].Operations;

         // Get the OperationMessageCollection for the Add operation.
         OperationMessageCollection myOperationMessageCollection =
            myOperationCollection[0].Messages;

         // Display the Flow, Input, and Output properties.
         DisplayFlowInputOutput(myOperationMessageCollection, "Start");

         // 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);
         DisplayFlowInputOutput(myOperationMessageCollection, "Add");

         if(myOperationMessageCollection.Contains(myOperationMessage))
         {
            int myIndex =
               myOperationMessageCollection.IndexOf(myOperationMessage);
            Console.WriteLine(" The index of the Add operation " +
               "message in the collection is : " + myIndex);
         }

         myOperationMessageCollection.Remove(myInputOperationMessage);

         // Display Flow, Input, and Output after removing.
         DisplayFlowInputOutput(myOperationMessageCollection, "Remove");

         // Insert the message at index 0 in the collection.
         myOperationMessageCollection.Insert(0, myInputOperationMessage);

         // Display Flow, Input, and Output after inserting.
         DisplayFlowInputOutput(myOperationMessageCollection, "Insert");

         myDescription.Write("MathService_new_cs.wsdl");
      }
      catch(Exception e)
      {
         Console.WriteLine("Exception caught!!!");
         Console.WriteLine("Source : " + e.Source);
         Console.WriteLine("Message : " + e.Message);
      }
   }

   // Displays the properties of the OperationMessageCollection.
   public static void DisplayFlowInputOutput( OperationMessageCollection
      myOperationMessageCollection, string myOperation)
   {
      Console.WriteLine("After " + myOperation + ":");
      Console.WriteLine("Flow : " + myOperationMessageCollection.Flow);
      Console.WriteLine("The first occurrence of operation Input " +
         "in the collection " + myOperationMessageCollection.Input);
      Console.WriteLine("The first occurrence of operation Output " +
         "in the collection " + myOperationMessageCollection.Output);
      Console.WriteLine();
   }
}
Imports System.Xml
Imports System.Web.Services
Imports System.Web.Services.Description

Class MyOperationMessageCollectionSample
   
   Shared Sub Main()
      Try
         Dim myDescription As ServiceDescription = _
            ServiceDescription.Read("MathService_input_vb.wsdl")
         Dim myPortTypeCollection As PortTypeCollection = _
            myDescription.PortTypes

         ' Get the OperationCollection for the SOAP protocol.
         Dim myOperationCollection As OperationCollection = _
            myPortTypeCollection(0).Operations

         ' Get the OperationMessageCollection for the Add operation.
         Dim myOperationMessageCollection As OperationMessageCollection = _
            myOperationCollection(0).Messages
         ' Display the Flow, Input, and Output properties.
         DisplayFlowInputOutput(myOperationMessageCollection, "Start")

         ' 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)
         DisplayFlowInputOutput(myOperationMessageCollection, "Add")
         
         If myOperationMessageCollection.Contains(myOperationMessage) _
            = True Then
            Dim myIndex As Integer = _
               myOperationMessageCollection.IndexOf(myOperationMessage)
            Console.WriteLine(" The index of the Add operation " & _
                "message in the collection is : " & myIndex.ToString())
         End If

         myOperationMessageCollection.Remove(myInputOperationMessage)

         ' Display Flow, Input, and Output after removing.
         DisplayFlowInputOutput(myOperationMessageCollection, "Remove")

         ' Insert the message at index 0 in the collection.
         myOperationMessageCollection.Insert(0, myInputOperationMessage)

         ' Display Flow, Input, and Output after inserting.
         DisplayFlowInputOutput(myOperationMessageCollection, "Insert")

         myDescription.Write("MathService_new_vb.wsdl")
      Catch e As Exception
         Console.WriteLine("Exception caught!!!")
         Console.WriteLine("Source : " & e.Source.ToString())
         Console.WriteLine("Message : " & e.Message.ToString())
      End Try
   End Sub
   
   ' Displays the properties of the OperationMessageCollection.
   Public Shared Sub DisplayFlowInputOutput(myOperationMessageCollection As  _
      OperationMessageCollection, myOperation As String)

      Console.WriteLine("After " & myOperation.ToString() & ":")
      Console.WriteLine("Flow : " & _
         myOperationMessageCollection.Flow.ToString())
      Console.WriteLine("The first occurrence of operation Input " & _
         "in the collection {0}" , myOperationMessageCollection.Input)
      Console.WriteLine("The first occurrence of operation Output " & _
         "in the collection " &  myOperationMessageCollection.Output.ToString())
      Console.WriteLine()
   End Sub
End Class

備註

此類別的實例將由 MessagesOperation的屬性 回傳。 因此,它可以有恰好兩個成員,一個是 , OperationInput 另一個是 OperationOutput

屬性

名稱 Description
Capacity

取得或設定 可以 CollectionBase 包含的元素數量。

(繼承來源 CollectionBase)
Count

取得該實例中包含 CollectionBase 的元素數量。 此屬性無法覆寫。

(繼承來源 CollectionBase)
Flow

得到由 OperationMessageCollection所支持的傳輸類型。

InnerList

取得包含實ArrayList例中元素清單的 。CollectionBase

(繼承來源 CollectionBase)
Input

在集合中首次出現 a OperationInput

Item[Int32]

取得或設定 在 OperationMessage 指定的零基索引處的值。

List

取得包含實IList例中元素清單的 。CollectionBase

(繼承來源 CollectionBase)
Output

在集合中首次出現 a OperationOutput

Table

獲得一個介面,實現鍵與值 ServiceDescriptionBaseCollection在 中的關聯。

(繼承來源 ServiceDescriptionBaseCollection)

方法

名稱 Description
Add(OperationMessage)

將指定的 OperationMessage 加入 的末尾 OperationMessageCollection

Clear()

移除實例中 CollectionBase 的所有物件。 此方法無法被覆蓋。

(繼承來源 CollectionBase)
Contains(OperationMessage)

判斷指定 OperationMessage 是否屬於 OperationMessageCollection

CopyTo(OperationMessage[], Int32)

將整個 OperationMessageCollection 資料複製到相容的一維陣列,類型為 OperationMessage,從目標陣列指定的零基索引開始。

Equals(Object)

判斷指定的物件是否等於目前的物件。

(繼承來源 Object)
GetEnumerator()

回傳一個枚舉器,會遍歷該 CollectionBase 實例。

(繼承來源 CollectionBase)
GetHashCode()

做為預設哈希函式。

(繼承來源 Object)
GetKey(Object)

回傳與引用傳遞值相關的鍵名稱。

(繼承來源 ServiceDescriptionBaseCollection)
GetType()

取得目前實例的 Type

(繼承來源 Object)
IndexOf(OperationMessage)

搜尋指定的 OperationMessage 索引,並回傳集合中首次出現的零為基礎索引。

Insert(Int32, OperationMessage)

將指定的 OperationMessage 加到 指定的 OperationMessageCollection 零基索引。

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(OperationMessage)

移除指定 OperationMessageOperationMessageCollection的首次出現。

RemoveAt(Int32)

移除實例指定索引 CollectionBase 的元素。 此方法無法被覆蓋。

(繼承來源 CollectionBase)
SetParent(Object, Object)

設定該實例的 ServiceDescriptionBaseCollection 父物件。

(繼承來源 ServiceDescriptionBaseCollection)
ToString()

傳回表示目前 物件的字串。

(繼承來源 Object)

明確介面實作

名稱 Description
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)

擴充方法

名稱 Description
AsParallel(IEnumerable)

啟用查詢的平行處理。

AsQueryable(IEnumerable)

IEnumerable 轉換成 IQueryable

Cast<TResult>(IEnumerable)

IEnumerable 的項目轉換成指定的型別。

OfType<TResult>(IEnumerable)

根據指定的型別篩選 IEnumerable 的專案。

適用於