MessagePartCollection Klasa

Definicja

Reprezentuje kolekcję wystąpień MessagePart klasy. Klasa ta nie może być dziedziczona.

public ref class MessagePartCollection sealed : System::Web::Services::Description::ServiceDescriptionBaseCollection
public sealed class MessagePartCollection : System.Web.Services.Description.ServiceDescriptionBaseCollection
type MessagePartCollection = class
    inherit ServiceDescriptionBaseCollection
Public NotInheritable Class MessagePartCollection
Inherits ServiceDescriptionBaseCollection
Dziedziczenie

Przykłady

W poniższym przykładzie pokazano użycie metod i właściwości uwidocznionych przez klasę MessagePartCollection .

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

using namespace System;
using namespace System::Web::Services::Description;
using namespace System::Collections;
using namespace System::Xml;
int main()
{
   Console::WriteLine( "" );
   Console::WriteLine( "MessagePartCollection Sample" );
   Console::WriteLine( "============================" );
   Console::WriteLine( "" );
   ServiceDescription^ myServiceDescription = ServiceDescription::Read( "MathService.wsdl" );

   // Get the message collection.
   MessageCollection^ myMessageCollection = myServiceDescription->Messages;
   Console::WriteLine( "Total Messages in the document = {0}", myServiceDescription->Messages->Count );
   Console::WriteLine( "" );
   Console::WriteLine( "Enumerating PartCollection for each message..." );
   Console::WriteLine( "" );

   // Get the message part collection for each message.
   for ( int i = 0; i < myMessageCollection->Count; ++i )
   {
      Console::WriteLine( "Message      : {0}", myMessageCollection[ i ]->Name );

      // Get the message part collection.
      MessagePartCollection^ myMessagePartCollection = myMessageCollection[ i ]->Parts;

      // Display the part collection.
      for ( int k = 0; k < myMessagePartCollection->Count; k++ )
      {
         Console::WriteLine( "\t       Part Name     : {0}", myMessagePartCollection[ k ]->Name );
         Console::WriteLine( "\t       Message Name  : {0}", myMessagePartCollection[ k ]->Message->Name );
      }
      Console::WriteLine( "" );
   }

   Console::WriteLine( "MessagePartCollection for the message AddHttpGetIn." );
   Message^ myLocalMessage = myServiceDescription->Messages[ "AddHttpPostOut" ];
   if ( myMessageCollection->Contains( myLocalMessage ) )
   {
      Console::WriteLine( "Message      : {0}", myLocalMessage->Name );

      // Get the message part collection.
      MessagePartCollection^ myMessagePartCollection = myLocalMessage->Parts;
      array<MessagePart^>^myMessagePart = gcnew array<MessagePart^>(myMessagePartCollection->Count);
      
      // Copy the MessagePartCollection to an array.
      myMessagePartCollection->CopyTo( myMessagePart, 0 );
      for ( int k = 0; k < myMessagePart->Length; k++ )
         Console::WriteLine( "\t       Part Name : {0}", myMessagePartCollection[ k ]->Name );
      Console::WriteLine( "" );
   }

   Console::WriteLine( "Checking if message is AddHttpPostOut..." );
   Message^ myMessage = myServiceDescription->Messages[ "AddHttpPostOut" ];
   if ( myMessageCollection->Contains( myMessage ) )
   {
      // Get the mssage part collection.
      MessagePartCollection^ myMessagePartCollection = myMessage->Parts;

      // Get the part named Body.
      MessagePart^ myMessagePart = myMessage->Parts[ "Body" ];
      if ( myMessagePartCollection->Contains( myMessagePart ) )
      {
         // Get the part named Body.
         Console::WriteLine( "Index of Body in MessagePart collection = {0}", myMessagePartCollection->IndexOf( myMessagePart ) );
         Console::WriteLine( "Deleting Body from MessagePart collection..." );
         myMessagePartCollection->Remove( myMessagePart );
         if ( myMessagePartCollection->IndexOf( myMessagePart ) == -1 )
                  Console::WriteLine( "from the message AddHttpPostOut." );
      }
   }
}
using System;
using System.Web.Services.Description;
using System.Collections;
using System.Xml;

class MyClass1
{
   public static void Main()
   {
      Console.WriteLine("");
      Console.WriteLine("MessagePartCollection Sample");
      Console.WriteLine("============================");
      Console.WriteLine("");

      ServiceDescription myServiceDescription =
         ServiceDescription.Read("MathService.wsdl");

      // Get the message collection.
      MessageCollection myMessageCollection = myServiceDescription.Messages;
      Console.WriteLine("Total Messages in the document = " +
         myServiceDescription.Messages.Count);
      Console.WriteLine("");
      Console.WriteLine("Enumerating PartCollection for each message...");
      Console.WriteLine("");
      // Get the message part collection for each message.
      for(int i =0; i < myMessageCollection.Count; ++i)
      {
         Console.WriteLine("Message      : " + myMessageCollection[i].Name);

         // Get the message part collection.
         MessagePartCollection myMessagePartCollection =
            myMessageCollection[i].Parts;

         // Display the part collection.
         for(int k = 0; k < myMessagePartCollection.Count;k++)
         {
            Console.WriteLine("\t       Part Name     : " +
               myMessagePartCollection[k].Name);
            Console.WriteLine("\t       Message Name  : " +
               myMessagePartCollection[k].Message.Name);
         }
         Console.WriteLine("");
      }
      Console.WriteLine("Displaying the array copied from the " +
         "MessagePartCollection for the message AddHttpGetIn.");
      Message myLocalMessage = myServiceDescription.Messages["AddHttpPostOut"];
      if (myMessageCollection.Contains(myLocalMessage))
      {
         Console.WriteLine("Message      : " + myLocalMessage.Name);

         // Get the message part collection.
         MessagePartCollection myMessagePartCollection = myLocalMessage.Parts;
         MessagePart[] myMessagePart  =
            new MessagePart[myMessagePartCollection.Count];

         // Copy the MessagePartCollection to an array.
         myMessagePartCollection.CopyTo(myMessagePart,0);
         for(int k = 0; k < myMessagePart.Length; k++)
         {
            Console.WriteLine("\t       Part Name : " +
               myMessagePartCollection[k].Name);
         }
         Console.WriteLine("");
      }

      Console.WriteLine("Checking if message is AddHttpPostOut...");
      Message myMessage = myServiceDescription.Messages["AddHttpPostOut"];
      if (myMessageCollection.Contains(myMessage))
      {
         // Get the message part collection.
         MessagePartCollection myMessagePartCollection = myMessage.Parts;

         // Get the part named Body.
         MessagePart myMessagePart = myMessage.Parts["Body"];
         if (myMessagePartCollection.Contains(myMessagePart))
         {
            // Get the index of the part named Body.
            Console.WriteLine("Index of Body in MessagePart collection = " +
               myMessagePartCollection.IndexOf(myMessagePart));
            Console.WriteLine("Deleting Body from MessagePart collection...");
            myMessagePartCollection.Remove(myMessagePart);
            if(myMessagePartCollection.IndexOf(myMessagePart)== -1)
            {
               Console.WriteLine("MessagePart Body successfully deleted " +
                  "from the message AddHttpPostOut.");
            }
         }
      }
   }
}
Imports System.Web.Services.Description
Imports System.Collections
Imports System.Xml

Class MyClass1
   Public Shared Sub Main()
      Console.WriteLine("")
      Console.WriteLine("MessagePartCollection Sample")
      Console.WriteLine("============================")
      Console.WriteLine("")

      Dim myServiceDescription As ServiceDescription = _
         ServiceDescription.Read("MathService.wsdl")
      ' Get the message collection.
      Dim myMessageCollection As MessageCollection = _
         myServiceDescription.Messages
      Console.WriteLine("Total Messages in the document = " & _
         myServiceDescription.Messages.Count.ToString)
      Console.WriteLine("")
      Console.WriteLine("Enumerating PartCollection for each message...")
      Console.WriteLine("")
      ' Get the message part collection for each message.
      Dim i As Integer
      For i =0 to myMessageCollection.Count-1
         Console.WriteLine("Message      : " & myMessageCollection(i).Name)

         ' Get the message part collection.
         Dim myMessagePartCollection As MessagePartCollection = _
            myMessageCollection(i).Parts

         ' Display the part collection.
         Dim k As Integer
         For k = 0 To myMessagePartCollection.Count - 1
            Console.WriteLine(ControlChars.Tab & "       Part Name     : " & _
               myMessagePartCollection(k).Name)
            Console.WriteLine(ControlChars.Tab & "       Message Name  : " & _
               myMessagePartCollection(k).Message.Name)
         Next k
         Console.WriteLine("")
      Next
      Console.WriteLine("Displaying the array copied from the " & _
         "MessagePartCollection for the message AddHttpGetIn.")
      Dim myLocalMessage As Message = _
         myServiceDescription.Messages("AddHttpPostOut")
      If myMessageCollection.Contains(myLocalMessage) Then
         Console.WriteLine("Message      : " & myLocalMessage.Name)

         ' Get the message part collection.
         Dim myMessagePartCollection As MessagePartCollection = _
            myLocalMessage.Parts
         Dim myMessagePart(myMessagePartCollection.Count) As MessagePart

         ' Copy the MessagePartCollection to an array.
         myMessagePartCollection.CopyTo(myMessagePart, 0)
         Dim k As Integer
         For k = 0 To myMessagePart.Length - 2
            Console.WriteLine(ControlChars.Tab & "       Part Name : " & _
               myMessagePartCollection(k).Name)
         Next k
         Console.WriteLine("")
      End If

      Console.WriteLine("Checking if message is AddHttpPostOut...")
      Dim myMessage As Message = myServiceDescription.Messages("AddHttpPostOut")
      If myMessageCollection.Contains(myMessage) Then

         ' Get the message part collection.
         Dim myMessagePartCollection As MessagePartCollection = myMessage.Parts

         ' Get the part named Body.
         Dim myMessagePart As MessagePart = myMessage.Parts("Body")
         If myMessagePartCollection.Contains(myMessagePart) Then

            ' Get the index of the part named Body.
            Console.WriteLine("Index of Body in MessagePart collection = " & _
               myMessagePartCollection.IndexOf(myMessagePart).ToString)
            Console.WriteLine("Deleting Body from MessagePart Collection...")
            myMessagePartCollection.Remove(myMessagePart)
            If myMessagePartCollection.IndexOf(myMessagePart) = -1 Then
               Console.WriteLine("MessagePart Body successfully deleted " & _
               "from the message AddHttpPostOut.")
            End If
         End If
      End If
   End Sub
End Class

Uwagi

Klasa MessagePart odpowiada elementowi WSDL (Web Services Description Language) <part> ujętemu <message><definitions> w element, który jest z kolei ujęta przez element główny. Aby uzyskać więcej informacji na temat języka WSDL, zobacz specyfikację WSDL .

Właściwości

Capacity

Pobiera lub ustawia liczbę elementów, które CollectionBase mogą zawierać.

(Odziedziczone po CollectionBase)
Count

Pobiera liczbę elementów zawartych w wystąpieniu CollectionBase . Nie można zastąpić tej właściwości.

(Odziedziczone po CollectionBase)
InnerList

Pobiera element ArrayList zawierający listę elementów w wystąpieniu CollectionBase .

(Odziedziczone po CollectionBase)
Item[Int32]

Pobiera lub ustawia wartość MessagePart określonego indeksu opartego na zerach.

Item[String]

Pobiera określony MessagePart przez jego nazwę.

List

Pobiera element IList zawierający listę elementów w wystąpieniu CollectionBase .

(Odziedziczone po CollectionBase)
Table

Pobiera interfejs implementujący skojarzenie kluczy i wartości w obiekcie ServiceDescriptionBaseCollection.

(Odziedziczone po ServiceDescriptionBaseCollection)

Metody

Add(MessagePart)

Dodaje określony MessagePart element na końcu elementu MessagePartCollection.

Clear()

Usuwa wszystkie obiekty z CollectionBase wystąpienia. Nie można zastąpić tej metody.

(Odziedziczone po CollectionBase)
Contains(MessagePart)

Zwraca wartość wskazującą, czy określony MessagePart element jest elementem członkowskim elementu MessagePartCollection.

CopyTo(MessagePart[], Int32)

Kopiuje całą MessagePartCollection do zgodnej jednowymiarowej tablicy typu MessagePart, zaczynając od określonego indeksu zerowego tablicy docelowej.

Equals(Object)

Określa, czy dany obiekt jest taki sam, jak bieżący obiekt.

(Odziedziczone po Object)
GetEnumerator()

Zwraca moduł wyliczający, który iteruje za pośrednictwem CollectionBase wystąpienia.

(Odziedziczone po CollectionBase)
GetHashCode()

Służy jako domyślna funkcja skrótu.

(Odziedziczone po Object)
GetKey(Object)

Zwraca nazwę klucza skojarzonego z wartością przekazaną przez odwołanie.

(Odziedziczone po ServiceDescriptionBaseCollection)
GetType()

Type Pobiera bieżące wystąpienie.

(Odziedziczone po Object)
IndexOf(MessagePart)

Wyszukuje określony MessagePart element i zwraca indeks zerowy pierwszego wystąpienia w kolekcji.

Insert(Int32, MessagePart)

Dodaje określony MessagePart element do określonego MessagePartCollection indeksu opartego na zera.

MemberwiseClone()

Tworzy płytkią kopię bieżącego Objectelementu .

(Odziedziczone po Object)
OnClear()

Czyści zawartość ServiceDescriptionBaseCollection wystąpienia.

(Odziedziczone po ServiceDescriptionBaseCollection)
OnClearComplete()

Wykonuje dodatkowe procesy niestandardowe po wyczyszczeniu zawartości CollectionBase wystąpienia.

(Odziedziczone po CollectionBase)
OnInsert(Int32, Object)

Wykonuje dodatkowe procesy niestandardowe przed wstawieniem nowego elementu do CollectionBase wystąpienia.

(Odziedziczone po CollectionBase)
OnInsertComplete(Int32, Object)

Wykonuje dodatkowe procesy niestandardowe po wstawieniu nowego elementu do elementu ServiceDescriptionBaseCollection.

(Odziedziczone po ServiceDescriptionBaseCollection)
OnRemove(Int32, Object)

Usuwa element z elementu ServiceDescriptionBaseCollection.

(Odziedziczone po ServiceDescriptionBaseCollection)
OnRemoveComplete(Int32, Object)

Wykonuje dodatkowe procesy niestandardowe po usunięciu CollectionBase elementu z wystąpienia.

(Odziedziczone po CollectionBase)
OnSet(Int32, Object, Object)

Zamienia jedną wartość na inną w obiekcie ServiceDescriptionBaseCollection.

(Odziedziczone po ServiceDescriptionBaseCollection)
OnSetComplete(Int32, Object, Object)

Wykonuje dodatkowe procesy niestandardowe po ustawieniu wartości w wystąpieniu CollectionBase .

(Odziedziczone po CollectionBase)
OnValidate(Object)

Wykonuje dodatkowe procesy niestandardowe podczas sprawdzania poprawności wartości.

(Odziedziczone po CollectionBase)
Remove(MessagePart)

Usuwa pierwsze wystąpienie określonego MessagePart elementu z elementu MessagePartCollection.

RemoveAt(Int32)

Usuwa element w określonym indeksie CollectionBase wystąpienia. Ta metoda nie jest zastępowana.

(Odziedziczone po CollectionBase)
SetParent(Object, Object)

Ustawia obiekt ServiceDescriptionBaseCollection nadrzędny wystąpienia.

(Odziedziczone po ServiceDescriptionBaseCollection)
ToString()

Zwraca ciąg reprezentujący bieżący obiekt.

(Odziedziczone po Object)

Jawne implementacje interfejsu

ICollection.CopyTo(Array, Int32)

Kopiuje całą CollectionBase do zgodnej jednowymiarowej Arraytablicy, zaczynając od określonego indeksu tablicy docelowej.

(Odziedziczone po CollectionBase)
ICollection.IsSynchronized

Pobiera wartość wskazującą, czy dostęp do elementu CollectionBase jest synchronizowany (bezpieczny wątek).

(Odziedziczone po CollectionBase)
ICollection.SyncRoot

Pobiera obiekt, który może służyć do synchronizowania dostępu do obiektu CollectionBase.

(Odziedziczone po CollectionBase)
IList.Add(Object)

Dodaje obiekt na końcu obiektu CollectionBase.

(Odziedziczone po CollectionBase)
IList.Contains(Object)

Określa, czy element CollectionBase zawiera określony element.

(Odziedziczone po CollectionBase)
IList.IndexOf(Object)

Wyszukuje określony Object element i zwraca indeks oparty na zerowym pierwszym wystąpieniu w całym CollectionBaseobiekcie .

(Odziedziczone po CollectionBase)
IList.Insert(Int32, Object)

Wstawia element do CollectionBase określonego indeksu.

(Odziedziczone po CollectionBase)
IList.IsFixedSize

Pobiera wartość wskazującą, czy rozmiar CollectionBase ma stały rozmiar.

(Odziedziczone po CollectionBase)
IList.IsReadOnly

Pobiera wartość wskazującą, czy kolekcja CollectionBase jest przeznaczona tylko do odczytu.

(Odziedziczone po CollectionBase)
IList.Item[Int32]

Pobiera lub ustawia element pod określonym indeksem.

(Odziedziczone po CollectionBase)
IList.Remove(Object)

Usuwa pierwsze wystąpienie określonego obiektu z obiektu CollectionBase.

(Odziedziczone po CollectionBase)

Metody rozszerzania

Cast<TResult>(IEnumerable)

Rzutuje elementy elementu IEnumerable na określony typ.

OfType<TResult>(IEnumerable)

Filtruje elementy elementu IEnumerable na podstawie określonego typu.

AsParallel(IEnumerable)

Umożliwia równoległość zapytania.

AsQueryable(IEnumerable)

Konwertuje element IEnumerable na .IQueryable

Dotyczy

Zobacz też