MimePartCollection 类


表示 MimePart 类的实例的集合。Represents a collection of instances of the MimePart class. 此类不能被继承。This class cannot be inherited.

public ref class MimePartCollection sealed : System::Collections::CollectionBase
public sealed class MimePartCollection : System.Collections.CollectionBase
type MimePartCollection = class
    inherit CollectionBase
Public NotInheritable Class MimePartCollection
Inherits CollectionBase


下面的示例演示如何使用由类公开的属性和方法 MimePartCollectionThe following example demonstrates the use of the properties and methods exposed by the MimePartCollection class.

#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." );
using System;
using System.Collections;
using System.Xml;
using System.Web.Services.Description;

public class MyMimePartCollection
   public static void Main()
      ServiceDescription myServiceDescription =
      ServiceDescriptionCollection myServiceDescriptionCol =
         new ServiceDescriptionCollection();
      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++)
            myOperationBinding =myBinding.Operations[i];
      OutputBinding myOutputBinding = myOperationBinding.Output;
      MimeMultipartRelatedBinding myMimeMultipartRelatedBinding = null;
      IEnumerator myIEnumerator = myOutputBinding.Extensions.GetEnumerator();
      // Create an instances of 'MimePartCollection'.
      MimePartCollection myMimePartCollection = new MimePartCollection();
      myMimePartCollection= myMimeMultipartRelatedBinding.Parts;

      Console.WriteLine("Total number of mimepart elements initially is: "
      // Create an instance of 'MimePart'.
      MimePart myMimePart=new MimePart();
      // Create an instance of 'MimeXmlBinding'.
      MimeXmlBinding myMimeXmlBinding = new MimeXmlBinding();
      myMimeXmlBinding.Part = "body";
      // Insert a mimepart at first position.
      Console.WriteLine("Inserting a mimepart object...");
         Console.WriteLine("'MimePart' is succesffully added at position: "
         Console.WriteLine("Total number of mimepart elements after inserting is: "
                              + myMimePartCollection.Count);
       Console.WriteLine("MimePartCollection_1_Output_CS.wsdl has been generated successfully.");
Imports System.Collections
Imports System.Xml
Imports System.Web.Services.Description

Public Class MyMimePartCollection
   Public Shared Sub Main()
      Dim myServiceDescription As ServiceDescription = ServiceDescription.Read _
      Dim myServiceDescriptionCol As New ServiceDescriptionCollection()
      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: " + _
      ' Create an instance of 'MimePart'.
      Dim myMimePart As New MimePart()
      ' Create an instance of 'MimeXmlBinding'.
      Dim myMimeXmlBinding As New MimeXmlBinding()
      myMimeXmlBinding.Part = "body"
      ' 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: " + _
         Console.WriteLine("Total number of mimepart elements after inserting is: " + _
      End If
      Console.WriteLine("MimePartCollection_1_Output_VB.wsdl has been generated successfully.")
   End Sub
End Class


MimePart集合中的每个都表示一个添加到的扩展性元素 MimeMultipartRelatedBinding ,并为相应的指定 MIME 类型 MessagePartEach MimePart within the collection represents an extensibility element added to a MimeMultipartRelatedBinding, and specifies the MIME type for a corresponding MessagePart.

有关为 XML Web services 指定协议的详细信息,请参阅使用 ASP.NET 的 Xml Web servicesFor more information about specifying protocols for XML Web services, see XML Web Services Using ASP.NET. 有关 Web 服务描述语言(WSDL)的详细信息,请参阅WSDL规范。For more information about Web Services Description Language (WSDL), see the WSDL specification.



初始化 MimePartCollection 类的新实例。Initializes a new instance of the MimePartCollection class.



获取或设置 CollectionBase 可包含的元素数。Gets or sets the number of elements that the CollectionBase can contain.

(继承自 CollectionBase)

获取 CollectionBase 实例中包含的元素数。Gets the number of elements contained in the CollectionBase instance. 不能重写此属性。This property cannot be overridden.

(继承自 CollectionBase)

获取一个 ArrayList,它包含 CollectionBase 实例中元素的列表。Gets an ArrayList containing the list of elements in the CollectionBase instance.

(继承自 CollectionBase)

获取或设置位于指定的从零开始的索引处的 MimePart 值。Gets or sets the value of a MimePart at the specified zero-based index.


获取一个 IList,它包含 CollectionBase 实例中元素的列表。Gets an IList containing the list of elements in the CollectionBase instance.

(继承自 CollectionBase)



将指定的 MimePart 添加到 MimePartCollection 的结尾。Adds the specified MimePart to the end of the MimePartCollection.


CollectionBase 实例移除所有对象。Removes all objects from the CollectionBase instance. 不能重写此方法。This method cannot be overridden.

(继承自 CollectionBase)

返回一个值,该值指示指定的 MimePart 是否是 MimePartCollection 的成员。Returns a value indicating whether the specified MimePart is a member of the MimePartCollection.

CopyTo(MimePart[], Int32)

将整个 MimePartCollection 复制到兼容的、MimePart 类型的一维数组(从目标数组的指定的从零开始的索引处开始复制)。Copies the entire MimePartCollection to a compatible one-dimensional array of type MimePart, starting at the specified zero-based index of the target array.


确定指定对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(继承自 Object)

返回循环访问 CollectionBase 实例的枚举器。Returns an enumerator that iterates through the CollectionBase instance.

(继承自 CollectionBase)

用作默认哈希函数。Serves as the default hash function.

(继承自 Object)

获取当前实例的 TypeGets the Type of the current instance.

(继承自 Object)

搜索指定的 MimePart,并返回集合中第一个匹配项的索引(从零开始)。Searches for the specified MimePart and returns the zero-based index of the first occurrence within the collection.

Insert(Int32, MimePart)

将指定的 MimePart 添加到 MimePartCollection 中的指定索引处。Adds the specified MimePart to the MimePartCollection at the specified index.


创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(继承自 Object)

清除 CollectionBase 实例的内容时执行其他自定义进程。Performs additional custom processes when clearing the contents of the CollectionBase instance.

(继承自 CollectionBase)

在清除 CollectionBase 实例的内容之后执行其他自定义进程。Performs additional custom processes after clearing the contents of the CollectionBase instance.

(继承自 CollectionBase)
OnInsert(Int32, Object)

在向 CollectionBase 实例中插入新元素之前执行其他自定义进程。Performs additional custom processes before inserting a new element into the CollectionBase instance.

(继承自 CollectionBase)
OnInsertComplete(Int32, Object)

在向 CollectionBase 实例中插入新元素之后执行其他自定义进程。Performs additional custom processes after inserting a new element into the CollectionBase instance.

(继承自 CollectionBase)
OnRemove(Int32, Object)

当从 CollectionBase 实例移除元素时执行其他自定义进程。Performs additional custom processes when removing an element from the CollectionBase instance.

(继承自 CollectionBase)
OnRemoveComplete(Int32, Object)

在从 CollectionBase 实例中移除元素之后执行其他自定义进程。Performs additional custom processes after removing an element from the CollectionBase instance.

(继承自 CollectionBase)
OnSet(Int32, Object, Object)

当在 CollectionBase 实例中设置值之前执行其他自定义进程。Performs additional custom processes before setting a value in the CollectionBase instance.

(继承自 CollectionBase)
OnSetComplete(Int32, Object, Object)

当在 CollectionBase 实例中设置值后执行其他自定义进程。Performs additional custom processes after setting a value in the CollectionBase instance.

(继承自 CollectionBase)

当验证值时执行其他自定义进程。Performs additional custom processes when validating a value.

(继承自 CollectionBase)

MimePart 中移除指定的 MimePartCollection 的第一个匹配项。Removes the first occurrence of the specified MimePart from the MimePartCollection.


移除 CollectionBase 实例的指定索引处的元素。Removes the element at the specified index of the CollectionBase instance. 此方法不可重写。This method is not overridable.

(继承自 CollectionBase)

返回表示当前对象的字符串。Returns a string that represents the current object.

(继承自 Object)


ICollection.CopyTo(Array, Int32)

从目标数组的指定索引处开始将整个 CollectionBase 复制到兼容的一维 ArrayCopies the entire CollectionBase to a compatible one-dimensional Array, starting at the specified index of the target array.

(继承自 CollectionBase)

获取一个值,该值指示是否同步对 CollectionBase 的访问(线程安全)。Gets a value indicating whether access to the CollectionBase is synchronized (thread safe).

(继承自 CollectionBase)

获取可用于同步对 CollectionBase 的访问的对象。Gets an object that can be used to synchronize access to the CollectionBase.

(继承自 CollectionBase)

将一个对象添加到 CollectionBase 的末尾。Adds an object to the end of the CollectionBase.

(继承自 CollectionBase)

确定 CollectionBase 是否包含特定元素。Determines whether the CollectionBase contains a specific element.

(继承自 CollectionBase)

搜索指定的 Object,并返回整个 CollectionBase 中第一个匹配项的从零开始的索引。Searches for the specified Object and returns the zero-based index of the first occurrence within the entire CollectionBase.

(继承自 CollectionBase)
IList.Insert(Int32, Object)

将元素插入 CollectionBase 的指定索引处。Inserts an element into the CollectionBase at the specified index.

(继承自 CollectionBase)

获取一个值,该值指示 CollectionBase 是否具有固定大小。Gets a value indicating whether the CollectionBase has a fixed size.

(继承自 CollectionBase)

获取一个值,该值指示 CollectionBase 是否为只读。Gets a value indicating whether the CollectionBase is read-only.

(继承自 CollectionBase)

获取或设置指定索引处的元素。Gets or sets the element at the specified index.

(继承自 CollectionBase)

CollectionBase 中移除特定对象的第一个匹配项。Removes the first occurrence of a specific object from the CollectionBase.

(继承自 CollectionBase)



IEnumerable 的元素强制转换为指定的类型。Casts the elements of an IEnumerable to the specified type.


根据指定类型筛选 IEnumerable 的元素。Filters the elements of an IEnumerable based on a specified type.


启用查询的并行化。Enables parallelization of a query.


IEnumerable 转换为 IQueryableConverts an IEnumerable to an IQueryable.