MessagePartCollection Klasa
Definicja
Ważny
Niektóre informacje dotyczą produktów przedpremierowych, które mogą zostać znacznie zmodyfikowane przed premierą. Microsoft nie udziela żadnych gwarancji, ani wyraźnych, ani domniemanych, dotyczących informacji podanych tutaj.
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
| Nazwa | Opis |
|---|---|
| Capacity |
Pobiera lub ustawia liczbę elementów, które CollectionBase mogą zawierać. (Dziedziczone od CollectionBase) |
| Count |
Pobiera liczbę elementów zawartych w wystąpieniu CollectionBase . Nie można zastąpić tej właściwości. (Dziedziczone od CollectionBase) |
| InnerList |
Pobiera element ArrayList zawierający listę elementów w wystąpieniu CollectionBase . (Dziedziczone od 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 . (Dziedziczone od CollectionBase) |
| Table |
Pobiera interfejs implementujący skojarzenie kluczy i wartości w obiekcie ServiceDescriptionBaseCollection. (Dziedziczone od ServiceDescriptionBaseCollection) |
Metody
| Nazwa | Opis |
|---|---|
| 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. (Dziedziczone od CollectionBase) |
| Contains(MessagePart) |
Zwraca wartość wskazującą, czy określony MessagePart element jest elementem członkowskim elementu |
| 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. (Dziedziczone od Object) |
| GetEnumerator() |
Zwraca moduł wyliczający, który iteruje za pośrednictwem CollectionBase wystąpienia. (Dziedziczone od CollectionBase) |
| GetHashCode() |
Służy jako domyślna funkcja skrótu. (Dziedziczone od Object) |
| GetKey(Object) |
Zwraca nazwę klucza skojarzonego z wartością przekazaną przez odwołanie. (Dziedziczone od ServiceDescriptionBaseCollection) |
| GetType() |
Type Pobiera bieżące wystąpienie. (Dziedziczone od 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 . (Dziedziczone od Object) |
| OnClear() |
Czyści zawartość ServiceDescriptionBaseCollection wystąpienia. (Dziedziczone od ServiceDescriptionBaseCollection) |
| OnClearComplete() |
Wykonuje dodatkowe procesy niestandardowe po wyczyszczeniu zawartości CollectionBase wystąpienia. (Dziedziczone od CollectionBase) |
| OnInsert(Int32, Object) |
Wykonuje dodatkowe procesy niestandardowe przed wstawieniem nowego elementu do CollectionBase wystąpienia. (Dziedziczone od CollectionBase) |
| OnInsertComplete(Int32, Object) |
Wykonuje dodatkowe procesy niestandardowe po wstawieniu nowego elementu do elementu ServiceDescriptionBaseCollection. (Dziedziczone od ServiceDescriptionBaseCollection) |
| OnRemove(Int32, Object) |
Usuwa element z elementu ServiceDescriptionBaseCollection. (Dziedziczone od ServiceDescriptionBaseCollection) |
| OnRemoveComplete(Int32, Object) |
Wykonuje dodatkowe procesy niestandardowe po usunięciu CollectionBase elementu z wystąpienia. (Dziedziczone od CollectionBase) |
| OnSet(Int32, Object, Object) |
Zamienia jedną wartość na inną w obiekcie ServiceDescriptionBaseCollection. (Dziedziczone od ServiceDescriptionBaseCollection) |
| OnSetComplete(Int32, Object, Object) |
Wykonuje dodatkowe procesy niestandardowe po ustawieniu wartości w wystąpieniu CollectionBase . (Dziedziczone od CollectionBase) |
| OnValidate(Object) |
Wykonuje dodatkowe procesy niestandardowe podczas sprawdzania poprawności wartości. (Dziedziczone od 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. (Dziedziczone od CollectionBase) |
| SetParent(Object, Object) |
Ustawia obiekt ServiceDescriptionBaseCollection nadrzędny wystąpienia. (Dziedziczone od ServiceDescriptionBaseCollection) |
| ToString() |
Zwraca ciąg reprezentujący bieżący obiekt. (Dziedziczone od Object) |
Implementacje interfejsów jawnych
| Nazwa | Opis |
|---|---|
| ICollection.CopyTo(Array, Int32) |
Kopiuje całą CollectionBase do zgodnej jednowymiarowej Arraytablicy, zaczynając od określonego indeksu tablicy docelowej. (Dziedziczone od CollectionBase) |
| ICollection.IsSynchronized |
Pobiera wartość wskazującą, czy dostęp do elementu CollectionBase jest synchronizowany (bezpieczny wątek). (Dziedziczone od CollectionBase) |
| ICollection.SyncRoot |
Pobiera obiekt, który może służyć do synchronizowania dostępu do obiektu CollectionBase. (Dziedziczone od CollectionBase) |
| IList.Add(Object) |
Dodaje obiekt na końcu obiektu CollectionBase. (Dziedziczone od CollectionBase) |
| IList.Contains(Object) |
Określa, czy element CollectionBase zawiera określony element. (Dziedziczone od CollectionBase) |
| IList.IndexOf(Object) |
Wyszukuje określony Object element i zwraca indeks oparty na zerowym pierwszym wystąpieniu w całym CollectionBaseobiekcie . (Dziedziczone od CollectionBase) |
| IList.Insert(Int32, Object) |
Wstawia element do CollectionBase określonego indeksu. (Dziedziczone od CollectionBase) |
| IList.IsFixedSize |
Pobiera wartość wskazującą, czy rozmiar CollectionBase ma stały rozmiar. (Dziedziczone od CollectionBase) |
| IList.IsReadOnly |
Pobiera wartość wskazującą, czy kolekcja CollectionBase jest przeznaczona tylko do odczytu. (Dziedziczone od CollectionBase) |
| IList.Item[Int32] |
Pobiera lub ustawia element pod określonym indeksem. (Dziedziczone od CollectionBase) |
| IList.Remove(Object) |
Usuwa pierwsze wystąpienie określonego obiektu z obiektu CollectionBase. (Dziedziczone od CollectionBase) |
Metody rozszerzania
| Nazwa | Opis |
|---|---|
| AsParallel(IEnumerable) |
Umożliwia równoległość zapytania. |
| AsQueryable(IEnumerable) |
Konwertuje element IEnumerable na .IQueryable |
| Cast<TResult>(IEnumerable) |
Rzutuje elementy elementu IEnumerable na określony typ. |
| OfType<TResult>(IEnumerable) |
Filtruje elementy elementu IEnumerable na podstawie określonego typu. |