Freigeben über


MimePartCollection-Klasse

Stellt eine Auflistung von Instanzen der MimePart-Klasse dar. Diese Klasse kann nicht geerbt werden.

Namespace: System.Web.Services.Description
Assembly: System.Web.Services (in system.web.services.dll)

Syntax

'Declaration
Public NotInheritable Class MimePartCollection
    Inherits CollectionBase
'Usage
Dim instance As MimePartCollection
public sealed class MimePartCollection : CollectionBase
public ref class MimePartCollection sealed : public CollectionBase
public final class MimePartCollection extends CollectionBase
public final class MimePartCollection extends CollectionBase

Hinweise

Jeder MimePart in der Auflistung stellt ein Erweiterbarkeitselement dar, das einem MimeMultipartRelatedBinding hinzugefügt wurde, und gibt den MIME-Typ für einen entsprechenden MessagePart an.

Weitere Informationen zum Angeben von Protokollen für XML-Webdienste finden Sie unter XML-Webdienste, die ASP.NET verwenden. Weitere Informationen über WSDL (Web Services Description Language) finden Sie in der Spezifikation unter http://www.w3.org/TR/wsdl/.

Beispiel

Das folgende Beispiel veranschaulicht die Verwendung der durch die MimePartCollection-Klasse verfügbar gemachten Eigenschaften und Methoden.

Imports System
Imports System.Collections
Imports System.Xml
Imports System.Web.Services.Description

Public Class MyMimePartCollection
   
   Public Shared Sub Main()
      Dim myServiceDescription As ServiceDescription = ServiceDescription.Read _
                                             ("MimePartCollection_1_Input_vb.wsdl")
      Dim myServiceDescriptionCol As New ServiceDescriptionCollection()
      myServiceDescriptionCol.Add(myServiceDescription)
      Dim myXmlQualifiedName As New XmlQualifiedName("MimeServiceHttpPost", "http://tempuri.org/")
      ' Create a 'Binding' object.
      Dim myBinding As Binding = myServiceDescriptionCol.GetBinding(myXmlQualifiedName)
      Dim myOperationBinding As OperationBinding = Nothing
      Dim i As Integer
      For i = 0 To myBinding.Operations.Count - 1
         If myBinding.Operations(i).Name.Equals("AddNumbers") Then
            myOperationBinding = myBinding.Operations(i)
         End If
      Next i
      Dim myOutputBinding As OutputBinding = myOperationBinding.Output
      Dim myMimeMultipartRelatedBinding As MimeMultipartRelatedBinding = Nothing
      Dim myIEnumerator As IEnumerator = myOutputBinding.Extensions.GetEnumerator()
      While myIEnumerator.MoveNext()
         myMimeMultipartRelatedBinding = CType(myIEnumerator.Current, MimeMultipartRelatedBinding)
      End While
      ' Create an instances of 'MimePartCollection'.
      Dim myMimePartCollection As New MimePartCollection()
      myMimePartCollection = myMimeMultipartRelatedBinding.Parts
      
      Console.WriteLine("Total number of mimepart elements initially is: " + _
                                          myMimePartCollection.Count.ToString())
      ' Create an instance of 'MimePart'.
      Dim myMimePart As New MimePart()
      ' Create an instance of 'MimeXmlBinding'.
      Dim myMimeXmlBinding As New MimeXmlBinding()
      myMimeXmlBinding.Part = "body"
      myMimePart.Extensions.Add(myMimeXmlBinding)
      ' Insert a mimepart at first position.
      myMimePartCollection.Insert(0, myMimePart)
      Console.WriteLine("Inserting a mimepart object...")
      If myMimePartCollection.Contains(myMimePart) Then
         Console.WriteLine("'MimePart' is succesffully added at position: " + _
                                             myMimePartCollection.IndexOf(myMimePart).ToString())
         Console.WriteLine("Total number of mimepart elements after inserting is: " + _
                                                myMimePartCollection.Count.ToString())
      End If
      myServiceDescription.Write("MimePartCollection_1_Output_VB.wsdl")
      Console.WriteLine("MimePartCollection_1_Output_VB.wsdl has been generated successfully.")
   End Sub 'Main
End Class 'MyMimePartCollection
using System;
using System.Collections;
using System.Xml; 
using System.Web.Services.Description;  

public class MyMimePartCollection
{
   public static void Main()
   {
      ServiceDescription myServiceDescription = 
         ServiceDescription.Read("MimePartCollection_1_Input_cs.wsdl");
      ServiceDescriptionCollection myServiceDescriptionCol = 
         new ServiceDescriptionCollection();
      myServiceDescriptionCol.Add(myServiceDescription);
      XmlQualifiedName  myXmlQualifiedName = 
         new  XmlQualifiedName("MimeServiceHttpPost","http://tempuri.org/");
      // Create a 'Binding' object.
      Binding myBinding = myServiceDescriptionCol.GetBinding(myXmlQualifiedName);
      OperationBinding myOperationBinding= null;
      for(int i=0; i<myBinding.Operations.Count; i++) 
      {
         if(myBinding.Operations[i].Name.Equals("AddNumbers"))
         {
            myOperationBinding =myBinding.Operations[i];
         }
      }
      OutputBinding myOutputBinding = myOperationBinding.Output;
      MimeMultipartRelatedBinding myMimeMultipartRelatedBinding = null;
      IEnumerator myIEnumerator = myOutputBinding.Extensions.GetEnumerator();
      while(myIEnumerator.MoveNext())
      { 
         myMimeMultipartRelatedBinding=(MimeMultipartRelatedBinding)myIEnumerator.Current;
      }
      // Create an instances of 'MimePartCollection'.
      MimePartCollection myMimePartCollection = new MimePartCollection();
      myMimePartCollection= myMimeMultipartRelatedBinding.Parts;
      
      Console.WriteLine("Total number of mimepart elements initially is: "
                                       +myMimePartCollection.Count);
      // Create an instance of 'MimePart'.
      MimePart myMimePart=new MimePart();
      // Create an instance of 'MimeXmlBinding'.
      MimeXmlBinding myMimeXmlBinding = new MimeXmlBinding();
      myMimeXmlBinding.Part = "body";
      myMimePart.Extensions.Add(myMimeXmlBinding);
      // Insert a mimepart at first position.
      myMimePartCollection.Insert(0,myMimePart);
      Console.WriteLine("Inserting a mimepart object...");
      if(myMimePartCollection.Contains(myMimePart))
      {
         Console.WriteLine("'MimePart' is succesffully added at position: "
                              +myMimePartCollection.IndexOf(myMimePart));
         Console.WriteLine("Total number of mimepart elements after inserting is: "
                              + myMimePartCollection.Count);
      }
       myServiceDescription.Write("MimePartCollection_1_Output_CS.wsdl");
       Console.WriteLine("MimePartCollection_1_Output_CS.wsdl has been generated successfully.");
   }
}
#using <System.dll>
#using <System.Xml.dll>
#using <System.Web.Services.dll>

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

int main()
{
   ServiceDescription^ myServiceDescription = ServiceDescription::Read( "MimePartCollection_1_Input_cpp.wsdl" );
   ServiceDescriptionCollection^ myServiceDescriptionCol = gcnew ServiceDescriptionCollection;
   myServiceDescriptionCol->Add( myServiceDescription );
   XmlQualifiedName^ myXmlQualifiedName = gcnew XmlQualifiedName( "MimeServiceHttpPost","http://tempuri.org/" );
   
   // Create a 'Binding' object.
   Binding^ myBinding = myServiceDescriptionCol->GetBinding( myXmlQualifiedName );
   OperationBinding^ myOperationBinding = nullptr;
   for ( int i = 0; i < myBinding->Operations->Count; i++ )
      if ( myBinding->Operations[ i ]->Name->Equals( "AddNumbers" ) )
            myOperationBinding = myBinding->Operations[ i ];

   OutputBinding^ myOutputBinding = myOperationBinding->Output;
   MimeMultipartRelatedBinding^ myMimeMultipartRelatedBinding = nullptr;
   IEnumerator^ myIEnumerator = myOutputBinding->Extensions->GetEnumerator();
   while ( myIEnumerator->MoveNext() )
      myMimeMultipartRelatedBinding = dynamic_cast<MimeMultipartRelatedBinding^>(myIEnumerator->Current);

   // Create an instances of 'MimePartCollection'.
   MimePartCollection^ myMimePartCollection = gcnew MimePartCollection;
   myMimePartCollection = myMimeMultipartRelatedBinding->Parts;
   Console::WriteLine( "Total number of mimepart elements initially is: {0}", myMimePartCollection->Count );

   // Create an instance of 'MimePart'.
   MimePart^ myMimePart = gcnew MimePart;

   // Create an instance of 'MimeXmlBinding'.
   MimeXmlBinding^ myMimeXmlBinding = gcnew MimeXmlBinding;
   myMimeXmlBinding->Part = "body";
   myMimePart->Extensions->Add( myMimeXmlBinding );

   // Insert a mimepart at first position.
   myMimePartCollection->Insert( 0, myMimePart );
   Console::WriteLine( "Inserting a mimepart object..." );
   if ( myMimePartCollection->Contains( myMimePart ) )
   {
      Console::WriteLine( "'MimePart' is succesffully added at position: {0}", myMimePartCollection->IndexOf( myMimePart ) );
      Console::WriteLine( "Total number of mimepart elements after inserting is: {0}", myMimePartCollection->Count );
   }

   myServiceDescription->Write( "MimePartCollection_1_Output_cpp.wsdl" );
   Console::WriteLine( "MimePartCollection_1_Output_cpp.wsdl has been generated successfully." );
}
import System.*;
import System.Collections.*;
import System.Xml.*;
import System.Web.Services.Description.*;

public class MyMimePartCollection
{
    public static void main(String[] args)
    {
        ServiceDescription myServiceDescription = 
            ServiceDescription.Read("MimePartCollection_1_Input_jsl.wsdl");
        ServiceDescriptionCollection myServiceDescriptionCol = 
            new ServiceDescriptionCollection();
        myServiceDescriptionCol.Add(myServiceDescription);
        XmlQualifiedName myXmlQualifiedName = 
            new XmlQualifiedName("MimeServiceHttpPost", "http://tempuri.org/");

        // Create a 'Binding' object.
        Binding myBinding = myServiceDescriptionCol.
            GetBinding(myXmlQualifiedName);
        OperationBinding myOperationBinding = null;
        for (int i = 0; i < myBinding.get_Operations().get_Count(); i++) {
            if (myBinding.get_Operations().get_Item(i).get_Name().
                Equals("AddNumbers")) {
                myOperationBinding = myBinding.get_Operations().get_Item(i);
            }
        }
        OutputBinding myOutputBinding = myOperationBinding.get_Output();
        MimeMultipartRelatedBinding myMimeMultipartRelatedBinding = null;
        IEnumerator myIEnumerator = 
            myOutputBinding.get_Extensions().GetEnumerator();
        while (myIEnumerator.MoveNext()) {
            myMimeMultipartRelatedBinding = 
                (MimeMultipartRelatedBinding)myIEnumerator.get_Current();
        }

        // Create an instances of 'MimePartCollection'.
        MimePartCollection myMimePartCollection = new MimePartCollection();
        myMimePartCollection = myMimeMultipartRelatedBinding.get_Parts();

        Console.WriteLine("Total number of mimepart elements initially is: " 
            + myMimePartCollection.get_Count());

        // Create an instance of 'MimePart'.
        MimePart myMimePart = new MimePart();

        // Create an instance of 'MimeXmlBinding'.
        MimeXmlBinding myMimeXmlBinding = new MimeXmlBinding();
        myMimeXmlBinding.set_Part("body");
        myMimePart.get_Extensions().Add(myMimeXmlBinding);

        // Insert a mimepart at first position.
        myMimePartCollection.Insert(0, myMimePart);
        Console.WriteLine("Inserting a mimepart object...");
        if (myMimePartCollection.Contains(myMimePart)) {
            Console.WriteLine("'MimePart' is succesffully added at position: " 
                + myMimePartCollection.IndexOf(myMimePart));
            Console.WriteLine("Total number of mimepart elements "
                + "after inserting is: " + myMimePartCollection.get_Count());
        }
        myServiceDescription.Write("MimePartCollection_1_Output_JSL.wsdl");
        Console.WriteLine("MimePartCollection_1_Output_JSL.wsdl has been "
            + "generated successfully.");
    } //main
} //MyMimePartCollection

Vererbungshierarchie

System.Object
   System.Collections.CollectionBase
    System.Web.Services.Description.MimePartCollection

Threadsicherheit

Alle öffentlichen statischen (Shared in Visual Basic) Member dieses Typs sind threadsicher. Bei Instanzmembern ist die Threadsicherheit nicht gewährleistet.

Plattformen

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.

Versionsinformationen

.NET Framework

Unterstützt in: 2.0, 1.1, 1.0

Siehe auch

Referenz

MimePartCollection-Member
System.Web.Services.Description-Namespace