MimePartCollection 類別
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
表示 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
公開的屬性和方法。
#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) |
方法
明確介面實作
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。 |