MimePartCollection 类

定义

表示 MimePart 类的实例的集合。 此类不能被继承。

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
继承
MimePartCollection

示例

下面的示例演示如何使用 类 MimePartCollection 公开的属性和方法。

#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 =
         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.");
   }
}
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
End Class

注解

MimePart集合中的每个 表示添加到 的MimeMultipartRelatedBinding扩展性元素,并为相应的 MessagePart指定 MIME 类型。

有关为 XML Web 服务指定协议的详细信息,请参阅 XML Web Services Using ASP.NET。 有关 Web 服务描述语言 (WSDL) 的详细信息,请参阅 WSDL 规范。

构造函数

MimePartCollection()

初始化 MimePartCollection 类的新实例。

属性

Capacity

获取或设置 CollectionBase 可包含的元素数。

(继承自 CollectionBase)
Count

获取 CollectionBase 实例中包含的元素数。 不能重写此属性。

(继承自 CollectionBase)
InnerList

获取一个 ArrayList,它包含 CollectionBase 实例中元素的列表。

(继承自 CollectionBase)
Item[Int32]

获取或设置位于指定的从零开始的索引处的 MimePart 值。

List

获取一个 IList,它包含 CollectionBase 实例中元素的列表。

(继承自 CollectionBase)

方法

Add(MimePart)

将指定的 MimePart 添加到 MimePartCollection 的结尾。

Clear()

CollectionBase 实例移除所有对象。 不能重写此方法。

(继承自 CollectionBase)
Contains(MimePart)

返回一个值,该值指示指定的 MimePart 是否是 MimePartCollection 的成员。

CopyTo(MimePart[], Int32)

将整个 MimePartCollection 复制到兼容的、MimePart 类型的一维数组(从目标数组的指定的从零开始的索引处开始复制)。

Equals(Object)

确定指定对象是否等于当前对象。

(继承自 Object)
GetEnumerator()

返回循环访问 CollectionBase 实例的枚举器。

(继承自 CollectionBase)
GetHashCode()

作为默认哈希函数。

(继承自 Object)
GetType()

获取当前实例的 Type

(继承自 Object)
IndexOf(MimePart)

搜索指定的 MimePart,并返回集合中第一个匹配项的索引(从零开始)。

Insert(Int32, MimePart)

将指定的 MimePart 添加到 MimePartCollection 中的指定索引处。

MemberwiseClone()

创建当前 Object 的浅表副本。

(继承自 Object)
OnClear()

清除 CollectionBase 实例的内容时执行其他自定义进程。

(继承自 CollectionBase)
OnClearComplete()

在清除 CollectionBase 实例的内容之后执行其他自定义进程。

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

在向 CollectionBase 实例中插入新元素之前执行其他自定义进程。

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

在向 CollectionBase 实例中插入新元素之后执行其他自定义进程。

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

当从 CollectionBase 实例移除元素时执行其他自定义进程。

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

在从 CollectionBase 实例中移除元素之后执行其他自定义进程。

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

当在 CollectionBase 实例中设置值之前执行其他自定义进程。

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

当在 CollectionBase 实例中设置值后执行其他自定义进程。

(继承自 CollectionBase)
OnValidate(Object)

当验证值时执行其他自定义进程。

(继承自 CollectionBase)
Remove(MimePart)

MimePart 中移除指定的 MimePartCollection 的第一个匹配项。

RemoveAt(Int32)

移除 CollectionBase 实例的指定索引处的元素。 此方法不可重写。

(继承自 CollectionBase)
ToString()

返回表示当前对象的字符串。

(继承自 Object)

显式接口实现

ICollection.CopyTo(Array, Int32)

从目标数组的指定索引处开始将整个 CollectionBase 复制到兼容的一维 Array

(继承自 CollectionBase)
ICollection.IsSynchronized

获取一个值,该值指示是否同步对 CollectionBase 的访问(线程安全)。

(继承自 CollectionBase)
ICollection.SyncRoot

获取可用于同步对 CollectionBase 的访问的对象。

(继承自 CollectionBase)
IList.Add(Object)

将对象添加到 CollectionBase 的结尾处。

(继承自 CollectionBase)
IList.Contains(Object)

确定 CollectionBase 是否包含特定元素。

(继承自 CollectionBase)
IList.IndexOf(Object)

搜索指定的 Object,并返回整个 CollectionBase 中第一个匹配项的从零开始的索引。

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

将元素插入 CollectionBase 的指定索引处。

(继承自 CollectionBase)
IList.IsFixedSize

获取一个值,该值指示 CollectionBase 是否具有固定大小。

(继承自 CollectionBase)
IList.IsReadOnly

获取一个值,该值指示 CollectionBase 是否为只读。

(继承自 CollectionBase)
IList.Item[Int32]

获取或设置指定索引处的元素。

(继承自 CollectionBase)
IList.Remove(Object)

CollectionBase 中移除特定对象的第一个匹配项。

(继承自 CollectionBase)

扩展方法

Cast<TResult>(IEnumerable)

IEnumerable 的元素强制转换为指定的类型。

OfType<TResult>(IEnumerable)

根据指定类型筛选 IEnumerable 的元素。

AsParallel(IEnumerable)

启用查询的并行化。

AsQueryable(IEnumerable)

IEnumerable 转换为 IQueryable

适用于