Поделиться через


OperationMessageCollection Класс

Определение

Представляет коллекцию и OperationOutput сообщения, OperationInput связанные с веб-службой XML. Этот класс не может быть унаследован.

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

Комментарии

Экземпляр этого класса будет возвращен свойством Messages родительского Operationобъекта. Таким образом, он может иметь ровно два члена, один OperationInput и другой OperationOutput.

Свойства

Имя Описание
Capacity

Возвращает или задает количество элементов, которые CollectionBase могут содержаться.

(Унаследовано от CollectionBase)
Count

Возвращает количество элементов, содержащихся в экземпляре CollectionBase . Это свойство нельзя переопределить.

(Унаследовано от CollectionBase)
Flow

Возвращает тип передачи, поддерживаемый параметром OperationMessageCollection.

InnerList

ArrayList Возвращает список элементов в экземпляреCollectionBase.

(Унаследовано от CollectionBase)
Input

Возвращает первое вхождение OperationInput коллекции.

Item[Int32]

Возвращает или задает значение указанного отсчитываемого OperationMessage от нуля индекса.

List

IList Возвращает список элементов в экземпляреCollectionBase.

(Унаследовано от CollectionBase)
Output

Возвращает первое вхождение OperationOutput коллекции.

Table

Возвращает интерфейс, реализующий связь ключей и значений в объекте ServiceDescriptionBaseCollection.

(Унаследовано от ServiceDescriptionBaseCollection)

Методы

Имя Описание
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)

Добавляет указанный OperationMessageOperationMessageCollection в указанный отсчитываемый от нуля индекс.

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)

Удаляет первое вхождение указанного OperationMessage из него OperationMessageCollection.

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)

Методы расширения

Имя Описание
AsParallel(IEnumerable)

Включает параллелизацию запроса.

AsQueryable(IEnumerable)

Преобразует IEnumerable в IQueryable.

Cast<TResult>(IEnumerable)

Приведение элементов IEnumerable к указанному типу.

OfType<TResult>(IEnumerable)

Фильтрует элементы IEnumerable на основе указанного типа.

Применяется к