ImportCollection Class
Provides a collection of instances of the Import class representing documents to be imported into the XML Web service. This class cannot be inherited.
For a list of all members of this type, see ImportCollection Members.
System.Object
System.Collections.CollectionBase
System.Web.Services.Description.ServiceDescriptionBaseCollection
System.Web.Services.Description.ImportCollection
[Visual Basic] NotInheritable Public Class ImportCollection Inherits ServiceDescriptionBaseCollection [C#] public sealed class ImportCollection : ServiceDescriptionBaseCollection [C++] public __gc __sealed class ImportCollection : public ServiceDescriptionBaseCollection [JScript] public class ImportCollection extends ServiceDescriptionBaseCollection
Thread Safety
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Remarks
The Import class corresponds to the Web Services Description Language (WSDL) <import> element that is enclosed by the root <definitions> element. For more information about WSDL, see the specification at http://www.w3.org/TR/wsdl/.
Example
[Visual Basic, C#, C++] The following example demonstrates a typical use of the ImportCollection class.
[Visual Basic] Imports System Imports System.Web.Services.Description Imports System.Xml Imports Microsoft.VisualBasic Class ServiceDescription_ImportCollection Public Shared Sub Main() Dim myServiceDescription As ServiceDescription = _ ServiceDescription.Read("StockQuoteService_vb.wsdl") Console.WriteLine(" ImportCollection Sample ") ' Get Import Collection. Dim myImportCollection As ImportCollection = myServiceDescription.Imports Console.WriteLine("Total Imports in the document = " + _ myServiceDescription.Imports.Count.ToString()) ' Print 'Import' properties to console. Dim i As Integer For i = 0 To myImportCollection.Count - 1 Console.WriteLine(ControlChars.Tab + _ "Import Namespace :{0} Import Location :{1} ", _ myImportCollection(i).Namespace, _ myImportCollection(i).Location) Next i Dim myImports(myServiceDescription.Imports.Count - 1) As Import ' Copy 'ImportCollection' to an array. myServiceDescription.Imports.CopyTo(myImports, 0) Console.WriteLine("Imports that are copied to Importarray ...") Dim j As Integer For j = 0 To myImports.Length - 1 Console.WriteLine(ControlChars.Tab + _ "Import Namespace :{0} Import Location :{1} ", _ myImports(j).Namespace, myImports(j).Location) Next j ' Get Import by Index. Dim myImport As Import = _ myServiceDescription.Imports(myServiceDescription.Imports.Count - 1) Console.WriteLine("Import by Index...") If myImportCollection.Contains(myImport) Then Console.WriteLine("Import Namespace '" + myImport.Namespace + _ "' is found in 'ImportCollection'.") Console.WriteLine("Index of '" + myImport.Namespace + _ "' in 'ImportCollection' = " + _ myImportCollection.IndexOf(myImport).ToString()) Console.WriteLine("Delete Import from 'ImportCollection'...") myImportCollection.Remove(myImport) If myImportCollection.IndexOf(myImport) = - 1 Then Console.WriteLine("Import is successfully removed from Import Collection.") End If End If End Sub 'Main End Class 'ServiceDescription_ImportCollection [C#] using System; using System.Web.Services.Description; using System.Xml; class ServiceDescription_ImportCollection { public static void Main() { ServiceDescription myServiceDescription = ServiceDescription.Read("StockQuoteService_cs.wsdl"); Console.WriteLine(" ImportCollection Sample "); // Get Import Collection. ImportCollection myImportCollection = myServiceDescription.Imports; Console.WriteLine("Total Imports in the document = " + myServiceDescription.Imports.Count); // Print 'Import' properties to console. for(int i =0; i < myImportCollection.Count; ++i) Console.WriteLine("\tImport Namespace :{0} Import Location :{1} " ,myImportCollection[i].Namespace ,myImportCollection[i].Location); Import[] myImports = new Import[myServiceDescription.Imports.Count]; // Copy 'ImportCollection' to an array. myServiceDescription.Imports.CopyTo(myImports,0); Console.WriteLine("Imports that are copied to Importarray ..."); for(int i=0;i < myImports.Length; ++i) Console.WriteLine("\tImport Namespace :{0} Import Location :{1} " ,myImports[i].Namespace ,myImports[i].Location); // Get Import by Index. Import myImport = myServiceDescription.Imports[myServiceDescription.Imports.Count-1]; Console.WriteLine("Import by Index..."); if (myImportCollection.Contains(myImport)) { Console.WriteLine("Import Namespace '" + myImport.Namespace + "' is found in 'ImportCollection'."); Console.WriteLine("Index of '" + myImport.Namespace + "' in 'ImportCollection' = " + myImportCollection.IndexOf(myImport)); Console.WriteLine("Deleting Import from 'ImportCollection'..."); myImportCollection.Remove(myImport); if(myImportCollection.IndexOf(myImport) == -1) Console.WriteLine("Import is successfully removed from Import Collection."); } } } [C++] #using <mscorlib.dll> #using <System.Web.Services.dll> #using <System.Xml.dll> using namespace System; using namespace System::Web::Services::Description; using namespace System::Xml; int main() { ServiceDescription * myServiceDescription = ServiceDescription::Read(S"StockQuoteService_cs.wsdl"); Console::WriteLine(S" ImportCollection Sample "); // Get Import Collection. ImportCollection * myImportCollection = myServiceDescription->Imports; Console::WriteLine(S"Total Imports in the document = {0}", __box(myServiceDescription -> Imports->Count)); // Print 'Import' properties to console. for (int i = 0; i < myImportCollection->Count; ++i) Console::WriteLine(S"\tImport Namespace : {0} Import Location : {1} " , myImportCollection->Item[i]->Namespace , myImportCollection->Item[i]->Location); Import* myImports[] = new Import*[myServiceDescription->Imports->Count]; // Copy 'ImportCollection' to an array. myServiceDescription->Imports->CopyTo(myImports, 0); Console::WriteLine(S"Imports that are copied to Importarray ..."); for (int i=0;i < myImports->Length; ++i) Console::WriteLine(S"\tImport Namespace : {0} Import Location : {1} ", myImports[i]->Namespace, myImports[i]->Location ); // Get Import by Index. Import * myImport = myServiceDescription->Imports->Item[myServiceDescription->Imports->Count-1]; Console::WriteLine(S"Import by Index..."); if (myImportCollection->Contains(myImport)) { Console::WriteLine(S"Import Namespace ' {0} ' is found in 'ImportCollection'.", myImport -> Namespace); Console::WriteLine(S"Index of '{0}' in 'ImportCollection' = {1}", myImport -> Namespace, __box(myImportCollection->IndexOf(myImport))); Console::WriteLine(S"Deleting Import from 'ImportCollection'..."); myImportCollection->Remove(myImport); if (myImportCollection->IndexOf(myImport) == -1) Console::WriteLine(S"Import is successfully removed from Import Collection."); } }
[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button
in the upper-left corner of the page.
Requirements
Namespace: System.Web.Services.Description
Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family
Assembly: System.Web.Services (in System.Web.Services.dll)
See Also
ImportCollection Members | System.Web.Services.Description Namespace | Import