Condividi tramite


OperationMessageCollection Classe

Definizione

Rappresenta una raccolta di OperationInput messaggi e OperationOutput correlati a un servizio Web XML. Questa classe non può essere ereditata.

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
Ereditarietà

Esempio

#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

Commenti

Un'istanza di questa classe verrà restituita dalla Messages proprietà dell'oggetto padre Operation. Di conseguenza, può avere esattamente due membri, uno OperationInput e l'altro .OperationOutput

Proprietà

Nome Descrizione
Capacity

Ottiene o imposta il numero di elementi che l'oggetto CollectionBase può contenere.

(Ereditato da CollectionBase)
Count

Ottiene il numero di elementi contenuti nell'istanza CollectionBase di . Impossibile eseguire l'override di questa proprietà.

(Ereditato da CollectionBase)
Flow

Ottiene il tipo di trasmissione supportato da OperationMessageCollection.

InnerList

Ottiene un oggetto ArrayList contenente l'elenco di elementi nell'istanza CollectionBase di .

(Ereditato da CollectionBase)
Input

Ottiene la prima occorrenza di un OperationInput oggetto all'interno dell'insieme.

Item[Int32]

Ottiene o imposta il valore di un oggetto OperationMessage in corrispondenza dell'indice in base zero specificato.

List

Ottiene un oggetto IList contenente l'elenco di elementi nell'istanza CollectionBase di .

(Ereditato da CollectionBase)
Output

Ottiene la prima occorrenza di un OperationOutput oggetto all'interno dell'insieme.

Table

Ottiene un'interfaccia che implementa l'associazione delle chiavi e dei valori in ServiceDescriptionBaseCollection.

(Ereditato da ServiceDescriptionBaseCollection)

Metodi

Nome Descrizione
Add(OperationMessage)

Aggiunge l'oggetto specificato OperationMessage alla fine dell'oggetto OperationMessageCollection.

Clear()

Rimuove tutti gli oggetti dall'istanza CollectionBase di . Non è possibile eseguire l'override di questo metodo.

(Ereditato da CollectionBase)
Contains(OperationMessage)

Determina se l'oggetto specificato OperationMessage è un membro dell'oggetto OperationMessageCollection.

CopyTo(OperationMessage[], Int32)

Copia l'intero OperationMessageCollection oggetto in una matrice unidimensionale compatibile di tipo OperationMessage, a partire dall'indice in base zero specificato della matrice di destinazione.

Equals(Object)

Determina se l'oggetto specificato è uguale all'oggetto corrente.

(Ereditato da Object)
GetEnumerator()

Restituisce un enumeratore che scorre l'istanza CollectionBase di .

(Ereditato da CollectionBase)
GetHashCode()

Funge da funzione hash predefinita.

(Ereditato da Object)
GetKey(Object)

Restituisce il nome della chiave associata al valore passato per riferimento.

(Ereditato da ServiceDescriptionBaseCollection)
GetType()

Ottiene il Type dell'istanza corrente.

(Ereditato da Object)
IndexOf(OperationMessage)

Cerca l'oggetto specificato OperationMessage e restituisce l'indice in base zero della prima occorrenza all'interno dell'insieme.

Insert(Int32, OperationMessage)

Aggiunge l'oggetto specificato OperationMessage all'oggetto OperationMessageCollection in corrispondenza dell'indice in base zero specificato.

MemberwiseClone()

Crea una copia superficiale del Objectcorrente.

(Ereditato da Object)
OnClear()

Cancella il contenuto dell'istanza di ServiceDescriptionBaseCollection.

(Ereditato da ServiceDescriptionBaseCollection)
OnClearComplete()

Esegue processi personalizzati aggiuntivi dopo la cancellazione del contenuto dell'istanza CollectionBase .

(Ereditato da CollectionBase)
OnInsert(Int32, Object)

Esegue processi personalizzati aggiuntivi prima di inserire un nuovo elemento nell'istanza CollectionBase di .

(Ereditato da CollectionBase)
OnInsertComplete(Int32, Object)

Esegue processi personalizzati aggiuntivi dopo l'inserimento di un nuovo elemento in ServiceDescriptionBaseCollection.

(Ereditato da ServiceDescriptionBaseCollection)
OnRemove(Int32, Object)

Rimuove un elemento da ServiceDescriptionBaseCollection.

(Ereditato da ServiceDescriptionBaseCollection)
OnRemoveComplete(Int32, Object)

Esegue processi personalizzati aggiuntivi dopo la rimozione di un elemento dall'istanza CollectionBase di .

(Ereditato da CollectionBase)
OnSet(Int32, Object, Object)

Sostituisce un valore con un altro all'interno di ServiceDescriptionBaseCollection.

(Ereditato da ServiceDescriptionBaseCollection)
OnSetComplete(Int32, Object, Object)

Esegue processi personalizzati aggiuntivi dopo aver impostato un valore nell'istanza CollectionBase di .

(Ereditato da CollectionBase)
OnValidate(Object)

Esegue processi personalizzati aggiuntivi durante la convalida di un valore.

(Ereditato da CollectionBase)
Remove(OperationMessage)

Rimuove la prima occorrenza dell'oggetto specificato OperationMessage da OperationMessageCollection.

RemoveAt(Int32)

Rimuove l'elemento in corrispondenza dell'indice specificato dell'istanza CollectionBase . Questo metodo non è sostituibile.

(Ereditato da CollectionBase)
SetParent(Object, Object)

Imposta l'oggetto padre dell'istanza ServiceDescriptionBaseCollection .

(Ereditato da ServiceDescriptionBaseCollection)
ToString()

Restituisce una stringa che rappresenta l'oggetto corrente.

(Ereditato da Object)

Implementazioni dell'interfaccia esplicita

Nome Descrizione
ICollection.CopyTo(Array, Int32)

Copia l'intero CollectionBase oggetto in un oggetto unidimensionale Arraycompatibile, a partire dall'indice specificato della matrice di destinazione.

(Ereditato da CollectionBase)
ICollection.IsSynchronized

Ottiene un valore che indica se l'accesso al CollectionBase è sincronizzato (thread-safe).

(Ereditato da CollectionBase)
ICollection.SyncRoot

Ottiene un oggetto che può essere utilizzato per sincronizzare l'accesso all'oggetto CollectionBase.

(Ereditato da CollectionBase)
IList.Add(Object)

Aggiunge un oggetto alla fine dell'oggetto CollectionBase.

(Ereditato da CollectionBase)
IList.Contains(Object)

Determina se contiene CollectionBase un elemento specifico.

(Ereditato da CollectionBase)
IList.IndexOf(Object)

Cerca l'oggetto specificato Object e restituisce l'indice in base zero della prima occorrenza all'interno dell'intero CollectionBaseoggetto .

(Ereditato da CollectionBase)
IList.Insert(Int32, Object)

Inserisce un elemento nell'oggetto CollectionBase in corrispondenza dell'indice specificato.

(Ereditato da CollectionBase)
IList.IsFixedSize

Ottiene un valore che indica se ha CollectionBase una dimensione fissa.

(Ereditato da CollectionBase)
IList.IsReadOnly

Ottiene un valore che indica se il CollectionBase è di sola lettura.

(Ereditato da CollectionBase)
IList.Item[Int32]

Ottiene o imposta l'elemento in corrispondenza dell'indice specificato.

(Ereditato da CollectionBase)
IList.Remove(Object)

Rimuove la prima occorrenza di un oggetto specifico da CollectionBase.

(Ereditato da CollectionBase)

Metodi di estensione

Nome Descrizione
AsParallel(IEnumerable)

Abilita la parallelizzazione di una query.

AsQueryable(IEnumerable)

Converte un IEnumerable in un IQueryable.

Cast<TResult>(IEnumerable)

Esegue il cast degli elementi di un IEnumerable al tipo specificato.

OfType<TResult>(IEnumerable)

Filtra gli elementi di un IEnumerable in base a un tipo specificato.

Si applica a