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 服务指定协议的详细信息,请参阅 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) |
方法
显式接口实现
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。 |