PortTypeCollection 类
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
表示 PortType 类的实例集合;即,XML Web service 所支持的操作组的集合。 此类不能被继承。
public ref class PortTypeCollection sealed : System::Web::Services::Description::ServiceDescriptionBaseCollection
public sealed class PortTypeCollection : System.Web.Services.Description.ServiceDescriptionBaseCollection
type PortTypeCollection = class
inherit ServiceDescriptionBaseCollection
Public NotInheritable Class PortTypeCollection
Inherits ServiceDescriptionBaseCollection
- 继承
示例
#using <System.Xml.dll>
#using <System.Web.Services.dll>
#using <System.dll>
using namespace System;
using namespace System::Web::Services::Description;
using namespace System::Xml;
using namespace System::Collections;
int main()
{
try
{
// Read the existing Web service description file.
ServiceDescription^ myServiceDescription = ServiceDescription::Read( "MathService_CS.wsdl" );
PortTypeCollection^ myPortTypeCollection = myServiceDescription->PortTypes;
int noOfPortTypes = myServiceDescription->PortTypes->Count;
Console::WriteLine( "\nTotal number of PortTypes: {0}", myServiceDescription->PortTypes->Count );
// Get the first PortType in the collection.
PortType^ myNewPortType = myPortTypeCollection[ "MathServiceSoap" ];
int index = myPortTypeCollection->IndexOf( myNewPortType );
Console::WriteLine( "The PortType with the name {0} is at index: {1}", myNewPortType->Name, (index + 1) );
Console::WriteLine( "Removing the PortType: {0}", myNewPortType->Name );
// Remove the PortType from the collection.
myPortTypeCollection->Remove( myNewPortType );
bool bContains = myPortTypeCollection->Contains( myNewPortType );
Console::WriteLine( "The PortType with the name {0} exists: {1}", myNewPortType->Name, bContains );
Console::WriteLine( "Total number of PortTypes after removing: {0}", myServiceDescription->PortTypes->Count );
Console::WriteLine( "Adding a PortType: {0}", myNewPortType->Name );
// Add a new portType from the collection.
myPortTypeCollection->Add( myNewPortType );
// Display the number of portTypes after adding a port.
Console::WriteLine( "Total number of PortTypes after adding a new port: {0}", myServiceDescription->PortTypes->Count );
// List the PortTypes available in the WSDL document.
IEnumerator^ myEnum = myPortTypeCollection->GetEnumerator();
while ( myEnum->MoveNext() )
{
PortType^ myPortType = safe_cast<PortType^>(myEnum->Current);
Console::WriteLine( "The PortType name is: {0}", myPortType->Name );
}
myServiceDescription->Write( "MathService_New.wsdl" );
}
catch ( Exception^ e )
{
Console::WriteLine( "Exception: {0}", e->Message );
}
}
using System;
using System.Web.Services.Description;
using System.Xml;
using System.Collections;
class MyPortTypeCollectionClass
{
public static void Main()
{
try
{
// Read the existing Web service description file.
ServiceDescription myServiceDescription =
ServiceDescription.Read("MathService_CS.wsdl");
PortTypeCollection myPortTypeCollection =
myServiceDescription.PortTypes;
int noOfPortTypes = myServiceDescription.PortTypes.Count;
Console.WriteLine("\nTotal number of PortTypes: "
+ myServiceDescription.PortTypes.Count);
// Get the first PortType in the collection.
PortType myNewPortType = myPortTypeCollection["MathServiceSoap"];
int index = myPortTypeCollection.IndexOf(myNewPortType);
Console.WriteLine("The PortType with the name " + myNewPortType.Name
+ " is at index: " + (index+1));
Console.WriteLine("Removing the PortType: " + myNewPortType.Name);
// Remove the PortType from the collection.
myPortTypeCollection.Remove(myNewPortType);
bool bContains = myPortTypeCollection.Contains(myNewPortType);
Console.WriteLine("The PortType with the name " + myNewPortType.Name
+ " exists: " + bContains);
Console.WriteLine("Total number of PortTypes after removing: "
+ myServiceDescription.PortTypes.Count);
Console.WriteLine("Adding a PortType: " + myNewPortType.Name);
// Add a new portType from the collection.
myPortTypeCollection.Add(myNewPortType);
// Display the number of portTypes after adding a port.
Console.WriteLine("Total number of PortTypes after "
+ "adding a new port: " + myServiceDescription.PortTypes.Count);
// List the PortTypes available in the WSDL document.
foreach(PortType myPortType in myPortTypeCollection)
Console.WriteLine("The PortType name is: " + myPortType.Name);
myServiceDescription.Write("MathService_New.wsdl");
}
catch(Exception e)
{
Console.WriteLine("Exception: " + e.Message);
}
}
}
Imports System.Web.Services.Description
Imports System.Xml
Imports System.Collections
Class MyPortTypeCollectionClass
Public Shared Sub Main()
Try
' Read the existing Web service description file.
Dim myServiceDescription As ServiceDescription = _
ServiceDescription.Read("MathService_vb.wsdl")
Dim myPortTypeCollection As PortTypeCollection = _
myServiceDescription.PortTypes
Dim noOfPortTypes As Integer = _
myServiceDescription.PortTypes.Count
Console.WriteLine( _
ControlChars.Newline & "Total number of PortTypes: " & _
myServiceDescription.PortTypes.Count.ToString())
' Get the first PortType in the collection.
Dim myNewPortType As PortType = _
myPortTypeCollection("MathServiceSoap")
Dim index As Integer = myPortTypeCollection.IndexOf(myNewPortType)
Console.WriteLine("The PortType with the name " & _
myNewPortType.Name & " is at index: " & (index + 1).ToString())
Console.WriteLine("Removing the PortType: " & myNewPortType.Name)
' Remove the PortType from the collection.
myPortTypeCollection.Remove(myNewPortType)
Dim bContains As Boolean = _
myPortTypeCollection.Contains(myNewPortType)
Console.WriteLine("The PortType with the Name " & _
myNewPortType.Name & " exists: " & bContains.ToString())
Console.WriteLine("Total Number of PortTypes after removing: " & _
myServiceDescription.PortTypes.Count.ToString())
Console.WriteLine("Adding a PortType: " & myNewPortType.Name)
' Add a new portType from the collection.
myPortTypeCollection.Add(myNewPortType)
' Display the number of portTypes after adding a port.
Console.WriteLine( _
"Total Number of PortTypes after adding a new port: " & _
myServiceDescription.PortTypes.Count.ToString())
' List the PortTypes available in the WSDL document.
Dim myPortType As PortType
For Each myPortType In myPortTypeCollection
Console.WriteLine("The PortType name is: " & myPortType.Name)
Next myPortType
myServiceDescription.Write("MathService_New.wsdl")
Catch e As Exception
Console.WriteLine("Exception: " & e.Message)
End Try
End Sub
End Class
属性
Capacity |
获取或设置 CollectionBase 可包含的元素数。 (继承自 CollectionBase) |
Count |
获取 CollectionBase 实例中包含的元素数。 不能重写此属性。 (继承自 CollectionBase) |
InnerList |
获取一个 ArrayList,它包含 CollectionBase 实例中元素的列表。 (继承自 CollectionBase) |
Item[Int32] |
获取或设置位于指定的从零开始的索引处的 PortType 值。 |
Item[String] |
获取由其名称指定的 PortType。 |
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。 |