PortCollection 类
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
表示 Port 类的实例的集合。 此类不能被继承。
public ref class PortCollection sealed : System::Web::Services::Description::ServiceDescriptionBaseCollection
public sealed class PortCollection : System.Web.Services.Description.ServiceDescriptionBaseCollection
type PortCollection = class
inherit ServiceDescriptionBaseCollection
Public NotInheritable Class PortCollection
Inherits ServiceDescriptionBaseCollection
- 继承
示例
Service^ myService;
PortCollection^ myPortCollection;
ServiceDescription^ myServiceDescription = ServiceDescription::Read( "MathServiceItem_cs.wsdl" );
Console::WriteLine( "Total number of services : {0}", myServiceDescription->Services->Count );
for ( int i = 0; i < myServiceDescription->Services->Count; ++i )
{
myService = myServiceDescription->Services[ i ];
Console::WriteLine( "Name : {0}", myService->Name );
myPortCollection = myService->Ports;
// Create an array of ports.
Console::WriteLine( "\nPort collection :" );
for ( int i1 = 0; i1 < myService->Ports->Count; ++i1 )
{
Console::WriteLine( "Port[{0}] : {1}", i1, myPortCollection[ i1 ]->Name );
}
String^ strPort = myPortCollection[ 0 ]->Name;
Port^ myPort = myPortCollection[ strPort ];
Console::WriteLine( "\nIndex of Port[{0}] : {1}", strPort, myPortCollection->IndexOf( myPort ) );
Port^ myPortTestRemove = myPortCollection[ 0 ];
Console::WriteLine( "\nTotal number of ports before removing a port '{0}' is : {1}", myPortTestRemove->Name, myService->Ports->Count );
myPortCollection->Remove( myPortTestRemove );
Console::WriteLine( "Total number of ports after removing a port '{0}' is : {1}", myPortTestRemove->Name, myService->Ports->Count );
// Create the WSDL file.
myPortCollection->Insert( 0, myPortTestRemove );
myServiceDescription->Write( "MathServiceItemNew_cs.wsdl" );
Service myService;
PortCollection myPortCollection;
ServiceDescription myServiceDescription =
ServiceDescription.Read("MathServiceItem_cs.wsdl");
Console.WriteLine("Total number of services : "
+ myServiceDescription.Services.Count);
for(int i=0; i < myServiceDescription.Services.Count; ++i)
{
myService = myServiceDescription.Services[i];
Console.WriteLine("Name : " + myService.Name);
myPortCollection = myService.Ports;
// Create an array of ports.
Console.WriteLine("\nPort collection :");
for(int i1=0 ; i1 < myService.Ports.Count ; ++i1)
{
Console.WriteLine("Port[" + i1+"] : " +
myPortCollection[i1].Name);
}
string strPort = myPortCollection[0].Name;
Port myPort = myPortCollection[strPort];
Console.WriteLine("\nIndex of Port[" + strPort + "] : " +
myPortCollection.IndexOf(myPort));
Port myPortTestRemove = myPortCollection[0];
Console.WriteLine("\nTotal number of ports before removing "
+ "a port '" + myPortTestRemove.Name +"' is : "
+ myService.Ports.Count);
myPortCollection.Remove(myPortTestRemove);
Console.WriteLine("Total number of ports after removing "
+ "a port '" + myPortTestRemove.Name +"' is : "
+ myService.Ports.Count);
// Create the WSDL file.
myPortCollection.Insert(0, myPortTestRemove);
myServiceDescription.Write("MathServiceItemNew_cs.wsdl");
Dim myService As Service
Dim myPortCollection As PortCollection
Dim myServiceDescription As ServiceDescription = _
ServiceDescription.Read("MathServiceItem_vb.wsdl")
Console.WriteLine("Total number of services : " & _
myServiceDescription.Services.Count.ToString)
Dim i As Integer
For i = 0 to myServiceDescription.Services.Count - 1
myService = myServiceDescription.Services(i)
Console.WriteLine("Name : " & myService.Name)
myPortCollection = myService.Ports
' Create an array of ports.
Console.WriteLine(ControlChars.NewLine & "Port collection :")
Dim i1 As Integer
For i1 = 0 to myService.Ports.Count - 1
Console.WriteLine("Port[" & i1.ToString & "] : " & _
myPortCollection(i1).Name)
Next
Dim strPort As String = myPortCollection(0).Name
Dim myPort As Port = myPortCollection(strPort)
Console.WriteLine(ControlChars.NewLine & _
"Index of Port[" & strPort & "] : " & _
myPortCollection.IndexOf(myPort).ToString)
Dim myPortTestRemove As Port = myPortCollection(0)
Console.WriteLine(ControlChars.NewLine & _
"Total number of ports before removing " & _
"a port '" & myPortTestRemove.Name & "' is : " & _
myService.Ports.Count.ToString)
myPortCollection.Remove(myPortTestRemove)
Console.WriteLine("Total number of ports after removing " & _
"a port '" & myPortTestRemove.Name & "' is : " & _
myService.Ports.Count.ToString)
' Create the WSDL file.
myPortCollection.Insert(0, myPortTestRemove)
myServiceDescription.Write("MathServiceItemNew_vb.wsdl")
Next
属性
Capacity |
获取或设置 CollectionBase 可包含的元素数。 (继承自 CollectionBase) |
Count |
获取 CollectionBase 实例中包含的元素数。 不能重写此属性。 (继承自 CollectionBase) |
InnerList |
获取一个 ArrayList,它包含 CollectionBase 实例中元素的列表。 (继承自 CollectionBase) |
Item[Int32] |
获取或设置位于指定的从零开始的索引处的 Port 值。 |
Item[String] |
获取由其名称指定的 Port。 |
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。 |