Export (0) Print
Expand All

MimePartCollection Class

Represents a collection of instances of the MimePart class. This class cannot be inherited.

Namespace:  System.Web.Services.Description
Assembly:  System.Web.Services (in System.Web.Services.dll)

public ref class MimePartCollection sealed : public CollectionBase

Each MimePart within the collection represents an extensibility element added to a MimeMultipartRelatedBinding, and specifies the MIME type for a corresponding MessagePart.

For more information about specifying protocols for XML Web services, see [<topic://cpconbuildingaspnetwebservices>]. For more information about Web Services Description Language (WSDL), see the specification at http://www.w3.org/TR/wsdl/.

The 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 <mscorlib.dll>
#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(S"MimePartCollection_1_Input_cs.wsdl");
   ServiceDescriptionCollection* myServiceDescriptionCol = new ServiceDescriptionCollection();
   myServiceDescriptionCol->Add(myServiceDescription);
   XmlQualifiedName* myXmlQualifiedName = 
      new XmlQualifiedName(S"MimeServiceHttpPost", S"http://tempuri.org/");
   // Create a 'Binding' object.
   Binding * myBinding = myServiceDescriptionCol->GetBinding(myXmlQualifiedName);
   OperationBinding* myOperationBinding = 0;
   for (int i=0; i<myBinding->Operations->Count; i++)
      if (myBinding->Operations->Item[i]->Name->Equals(S"AddNumbers"))
         myOperationBinding =myBinding->Operations->Item[i];
   OutputBinding * myOutputBinding = myOperationBinding->Output;
   MimeMultipartRelatedBinding* myMimeMultipartRelatedBinding = 0;
   IEnumerator* myIEnumerator = myOutputBinding->Extensions->GetEnumerator();
   while(myIEnumerator->MoveNext())
      myMimeMultipartRelatedBinding = dynamic_cast<MimeMultipartRelatedBinding*>(myIEnumerator->Current);

   // Create an instances of 'MimePartCollection'.
   MimePartCollection* myMimePartCollection = new MimePartCollection();
   myMimePartCollection= myMimeMultipartRelatedBinding->Parts;

   Console::WriteLine(S"Total number of mimepart elements initially is: {0}", 
      __box(myMimePartCollection->Count));
   // Create an instance of 'MimePart'.
   MimePart* myMimePart = new MimePart();
   // Create an instance of 'MimeXmlBinding'.
   MimeXmlBinding* myMimeXmlBinding = new MimeXmlBinding();
   myMimeXmlBinding->Part = S"body";
   myMimePart->Extensions->Add(myMimeXmlBinding);
   // Insert a mimepart at first position.
   myMimePartCollection->Insert(0, myMimePart);
   Console::WriteLine(S"Inserting a mimepart object...");
   if (myMimePartCollection->Contains(myMimePart))
   {
      Console::WriteLine(S"'MimePart' is succesffully added at position: {0}", 
         __box(myMimePartCollection->IndexOf(myMimePart)));
      Console::WriteLine(S"Total number of mimepart elements after inserting is: {0}", __box(myMimePartCollection->Count));
   }
   myServiceDescription->Write(S"MimePartCollection_1_Output_cs.wsdl");
   Console::WriteLine(S"MimePartCollection_1_Output_cs.wsdl has been generated successfully.");
}

System::Object
  System.Collections::CollectionBase
    System.Web.Services.Description::MimePartCollection

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1, 1.0

Community Additions

ADD
Show:
© 2015 Microsoft