共用方式為


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 服務的通訊協議的詳細資訊,請參閱 使用 ASP.NET 的 XML Web 服務。 如需 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)

複製整個 MimePartCollectionMimePart 型別的相容一維陣列,從目標陣列的指定以零起始的索引位置開始。

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

適用於