Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
MimePartCollection Class
Collapse the table of content
Expand the table of content

MimePartCollection Class

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

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

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

'Declaration
Public NotInheritable Class MimePartCollection _
	Inherits CollectionBase

The MimePartCollection type exposes the following members.

  NameDescription
Public methodMimePartCollectionInitializes a new instance of the MimePartCollection class.
Top

  NameDescription
Public propertyCapacityGets or sets the number of elements that the CollectionBase can contain. (Inherited from CollectionBase.)
Public propertyCountGets the number of elements contained in the CollectionBase instance. This property cannot be overridden. (Inherited from CollectionBase.)
Public propertyItemGets or sets the value of a MimePart at the specified zero-based index.
Top

  NameDescription
Public methodAddAdds the specified MimePart to the end of the MimePartCollection.
Public methodClearRemoves all objects from the CollectionBase instance. This method cannot be overridden. (Inherited from CollectionBase.)
Public methodContainsReturns a value indicating whether the specified MimePart is a member of the MimePartCollection.
Public methodCopyToCopies the entire MimePartCollection to a compatible one-dimensional array of type MimePart, starting at the specified zero-based index of the target array.
Public methodEquals(Object)Determines whether the specified object is equal to the current object. (Inherited from Object.)
Public methodGetEnumeratorReturns an enumerator that iterates through the CollectionBase instance. (Inherited from CollectionBase.)
Public methodGetHashCodeServes as the default hash function. (Inherited from Object.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodIndexOfSearches for the specified MimePart and returns the zero-based index of the first occurrence within the collection.
Public methodInsertAdds the specified MimePart to the MimePartCollection at the specified index.
Public methodRemoveRemoves the first occurrence of the specified MimePart from the MimePartCollection.
Public methodRemoveAtRemoves the element at the specified index of the CollectionBase instance. This method is not overridable. (Inherited from CollectionBase.)
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)
Top

  NameDescription
Explicit interface implemetationPrivate methodICollection.CopyToCopies the entire CollectionBase to a compatible one-dimensional Array, starting at the specified index of the target array. (Inherited from CollectionBase.)
Explicit interface implemetationPrivate propertyICollection.IsSynchronizedGets a value indicating whether access to the CollectionBase is synchronized (thread safe). (Inherited from CollectionBase.)
Explicit interface implemetationPrivate propertyICollection.SyncRootGets an object that can be used to synchronize access to the CollectionBase. (Inherited from CollectionBase.)
Explicit interface implemetationPrivate methodIList.AddAdds an object to the end of the CollectionBase. (Inherited from CollectionBase.)
Explicit interface implemetationPrivate methodIList.ContainsDetermines whether the CollectionBase contains a specific element. (Inherited from CollectionBase.)
Explicit interface implemetationPrivate methodIList.IndexOfSearches for the specified Object and returns the zero-based index of the first occurrence within the entire CollectionBase. (Inherited from CollectionBase.)
Explicit interface implemetationPrivate methodIList.InsertInserts an element into the CollectionBase at the specified index. (Inherited from CollectionBase.)
Explicit interface implemetationPrivate propertyIList.IsFixedSizeGets a value indicating whether the CollectionBase has a fixed size. (Inherited from CollectionBase.)
Explicit interface implemetationPrivate propertyIList.IsReadOnlyGets a value indicating whether the CollectionBase is read-only. (Inherited from CollectionBase.)
Explicit interface implemetationPrivate propertyIList.ItemGets or sets the element at the specified index. (Inherited from CollectionBase.)
Explicit interface implemetationPrivate methodIList.RemoveRemoves the first occurrence of a specific object from the CollectionBase. (Inherited from CollectionBase.)
Top

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

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

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