ImportCollection 类
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
提供 Import 类的实例集合,该类表示要导入到 XML Web 服务的文档。 此类不能被继承。
public ref class ImportCollection sealed : System::Web::Services::Description::ServiceDescriptionBaseCollection
public sealed class ImportCollection : System.Web.Services.Description.ServiceDescriptionBaseCollection
type ImportCollection = class
inherit ServiceDescriptionBaseCollection
Public NotInheritable Class ImportCollection
Inherits ServiceDescriptionBaseCollection
- 继承
示例
以下示例演示类 ImportCollection
的典型用法。
#using <System.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( "StockQuoteService_cpp.wsdl" );
Console::WriteLine( " ImportCollection Sample " );
// Get Import Collection.
ImportCollection^ myImportCollection = myServiceDescription->Imports;
Console::WriteLine( "Total Imports in the document = {0}", 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 );
array<Import^>^myImports = gcnew array<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 ' {0} ' is found in 'ImportCollection'.", myImport->Namespace );
Console::WriteLine( "Index of '{0}' in 'ImportCollection' = {1}",
myImport->Namespace, 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." );
}
}
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.");
}
}
}
Imports System.Web.Services.Description
Imports System.Xml
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
End Class
注解
该Import类对应于根<definitions>
元素括起来的 Web 服务描述语言 (WSDL) <import>
元素。 有关 WSDL 的更多信息,请参阅 WSDL 规范。
属性
Capacity |
获取或设置 CollectionBase 可包含的元素数。 (继承自 CollectionBase) |
Count |
获取 CollectionBase 实例中包含的元素数。 不能重写此属性。 (继承自 CollectionBase) |
InnerList |
获取一个 ArrayList,它包含 CollectionBase 实例中元素的列表。 (继承自 CollectionBase) |
Item[Int32] |
获取或设置位于指定的从零开始的索引处的 Import 的值。 |
List |
获取一个 IList,它包含 CollectionBase 实例中元素的列表。 (继承自 CollectionBase) |
Table |
获取实现 ServiceDescriptionBaseCollection 中键和值的关联的接口。 (继承自 ServiceDescriptionBaseCollection) |
方法
显式接口实现
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。 |