This documentation is archived and is not being maintained.

MimePartCollection Class

Represents a collection of instances of the MimePart class. This class cannot be inherited.

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

'Declaration
Public NotInheritable Class MimePartCollection _
	Inherits CollectionBase
'Usage
Dim instance As MimePartCollection

Each MimePart within the collection represents an extensibility element added to a MimeMultipartRelatedBinding, and specifies the MIME type for a corresponding MessagePart.

For more information about specifying protocols for XML Web services, see [<topic://cpconbuildingaspnetwebservices>]. For more information about Web Services Description Language (WSDL), see the specification at http://www.w3.org/TR/wsdl/.

The following example demonstrates the use of the properties and methods exposed by the MimePartCollection class.

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 <mscorlib.dll>
#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(S"MimePartCollection_1_Input_cs.wsdl");
   ServiceDescriptionCollection* myServiceDescriptionCol = new ServiceDescriptionCollection();
   myServiceDescriptionCol->Add(myServiceDescription);
   XmlQualifiedName* myXmlQualifiedName = 
      new XmlQualifiedName(S"MimeServiceHttpPost", S"http://tempuri.org/");
   // Create a 'Binding' object.
   Binding * myBinding = myServiceDescriptionCol->GetBinding(myXmlQualifiedName);
   OperationBinding* myOperationBinding = 0;
   for (int i=0; i<myBinding->Operations->Count; i++)
      if (myBinding->Operations->Item[i]->Name->Equals(S"AddNumbers"))
         myOperationBinding =myBinding->Operations->Item[i];
   OutputBinding * myOutputBinding = myOperationBinding->Output;
   MimeMultipartRelatedBinding* myMimeMultipartRelatedBinding = 0;
   IEnumerator* myIEnumerator = myOutputBinding->Extensions->GetEnumerator();
   while(myIEnumerator->MoveNext())
      myMimeMultipartRelatedBinding = dynamic_cast<MimeMultipartRelatedBinding*>(myIEnumerator->Current);

   // Create an instances of 'MimePartCollection'.
   MimePartCollection* myMimePartCollection = new MimePartCollection();
   myMimePartCollection= myMimeMultipartRelatedBinding->Parts;

   Console::WriteLine(S"Total number of mimepart elements initially is: {0}", 
      __box(myMimePartCollection->Count));
   // Create an instance of 'MimePart'.
   MimePart* myMimePart = new MimePart();
   // Create an instance of 'MimeXmlBinding'.
   MimeXmlBinding* myMimeXmlBinding = new MimeXmlBinding();
   myMimeXmlBinding->Part = S"body";
   myMimePart->Extensions->Add(myMimeXmlBinding);
   // Insert a mimepart at first position.
   myMimePartCollection->Insert(0, myMimePart);
   Console::WriteLine(S"Inserting a mimepart object...");
   if (myMimePartCollection->Contains(myMimePart))
   {
      Console::WriteLine(S"'MimePart' is succesffully added at position: {0}", 
         __box(myMimePartCollection->IndexOf(myMimePart)));
      Console::WriteLine(S"Total number of mimepart elements after inserting is: {0}", __box(myMimePartCollection->Count));
   }
   myServiceDescription->Write(S"MimePartCollection_1_Output_cs.wsdl");
   Console::WriteLine(S"MimePartCollection_1_Output_cs.wsdl has been generated successfully.");
}

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

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

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

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1, 1.0
Show: