ServiceDescriptionBaseCollection 类
定义
构成强类型化集合的基础,它们是 System.Web.Services.Description 命名空间的成员。Forms the basis for the strongly typed collections that are members of the System.Web.Services.Description namespace.
public ref class ServiceDescriptionBaseCollection abstract : System::Collections::CollectionBase
public abstract class ServiceDescriptionBaseCollection : System.Collections.CollectionBase
type ServiceDescriptionBaseCollection = class
inherit CollectionBase
Public MustInherit Class ServiceDescriptionBaseCollection
Inherits CollectionBase
- 继承
- 派生
示例
static void MyMethod( ServiceDescriptionBaseCollection^ myServiceCollection )
{
Type^ myType = myServiceCollection->GetType();
if ( myType->Equals( System::Web::Services::Description::ServiceCollection::typeid ) )
{
// Remove the services at index 0 of the collection.
(dynamic_cast<ServiceCollection^>(myServiceCollection))->Remove( myServiceDescription->Services[ 0 ] );
// Build a new Service.
Service^ myService = gcnew Service;
myService->Name = "MathService";
XmlQualifiedName^ myXmlQualifiedName = gcnew XmlQualifiedName( "s0:MathServiceSoap" );
// Build a new Port for SOAP.
Port^ mySoapPort = gcnew Port;
mySoapPort->Name = "MathServiceSoap";
mySoapPort->Binding = myXmlQualifiedName;
SoapAddressBinding^ mySoapAddressBinding = gcnew SoapAddressBinding;
mySoapAddressBinding->Location = "http://localhost/"
"ServiceDescriptionBaseCollection/AddSubtractService.CS.asmx";
mySoapPort->Extensions->Add( mySoapAddressBinding );
// Build a new Port for HTTP-GET.
XmlQualifiedName^ myXmlQualifiedName2 = gcnew XmlQualifiedName( "s0:MathServiceHttpGet" );
Port^ myHttpGetPort = gcnew Port;
myHttpGetPort->Name = "MathServiceHttpGet";
myHttpGetPort->Binding = myXmlQualifiedName2;
HttpAddressBinding^ myHttpAddressBinding = gcnew HttpAddressBinding;
myHttpAddressBinding->Location = "http://localhost/"
"ServiceDescriptionBaseCollection/AddSubtractService.CS.asmx";
myHttpGetPort->Extensions->Add( myHttpAddressBinding );
// Add the ports to the Service.
myService->Ports->Add( myHttpGetPort );
myService->Ports->Add( mySoapPort );
// Add the Service to the ServiceCollection.
myServiceDescription->Services->Add( myService );
}
else
if ( myType->Equals( System::Web::Services::Description::BindingCollection::typeid ) )
{
// Remove the Binding in the BindingCollection at index 0.
(dynamic_cast<BindingCollection^>(myServiceCollection))->Remove( myServiceDescription->Bindings[ 0 ] );
// Build a new Binding.
Binding^ myBinding = gcnew Binding;
myBinding->Name = "MathServiceSoap";
XmlQualifiedName^ myXmlQualifiedName = gcnew XmlQualifiedName( "s0:MathServiceSoap" );
myBinding->Type = myXmlQualifiedName;
SoapBinding^ mySoapBinding = gcnew SoapBinding;
mySoapBinding->Transport = "http://schemas.xmlsoap.org/soap/http";
mySoapBinding->Style = SoapBindingStyle::Document;
// Create the operations for the binding.
OperationBinding^ addOperationBinding = CreateOperationBinding( "Add", myServiceDescription->TargetNamespace );
OperationBinding^ subtractOperationBinding = CreateOperationBinding( "Subtract", myServiceDescription->TargetNamespace );
// Add the operations to the Binding.
myBinding->Operations->Add( subtractOperationBinding );
myBinding->Operations->Add( addOperationBinding );
myBinding->Extensions->Add( mySoapBinding );
// Add the Binding to the Bindings collection.
myServiceDescription->Bindings->Add( myBinding );
}
else
if ( myType->Equals( System::Web::Services::Description::PortTypeCollection::typeid ) )
{
// Remove the PortType at index 0.
(dynamic_cast<PortTypeCollection^>(myServiceCollection))->Remove( myServiceDescription->PortTypes[ 0 ] );
// Build a new PortType.
PortType^ myPortType = gcnew PortType;
myPortType->Name = "MathServiceSoap";
// Build an Add Operation for the PortType.
Operation^ myAddOperation = gcnew Operation;
myAddOperation->Name = "Add";
// Build the Input and Output messages for the Operations.
OperationInput^ myOperationInputMessage1 = gcnew OperationInput;
XmlQualifiedName^ myXmlQualifiedName1 = gcnew XmlQualifiedName( "s0:AddSoapIn" );
myOperationInputMessage1->Message = myXmlQualifiedName1;
OperationOutput^ myOperationOutputMessage1 = gcnew OperationOutput;
XmlQualifiedName^ myXmlQualifiedName2 = gcnew XmlQualifiedName( "s0:AddSoapOut" );
myOperationOutputMessage1->Message = myXmlQualifiedName2;
// Add the messages to the operations.
myAddOperation->Messages->Add( myOperationInputMessage1 );
myAddOperation->Messages->Add( myOperationOutputMessage1 );
// Build an Add Operation for the PortType.
Operation^ mySubtractOperation = gcnew Operation;
mySubtractOperation->Name = "Subtract";
// Build the Input and Output messages for the operations.
OperationInput^ myOperationInputMessage2 = gcnew OperationInput;
XmlQualifiedName^ myXmlQualifiedName3 = gcnew XmlQualifiedName( "s0:SubtractSoapIn" );
myOperationInputMessage2->Message = myXmlQualifiedName3;
OperationOutput^ myOperationOutputMessage2 = gcnew OperationOutput;
XmlQualifiedName^ myXmlQualifiedName4 = gcnew XmlQualifiedName( "s0:SubtractSoapOut" );
myOperationOutputMessage2->Message = myXmlQualifiedName4;
// Add the messages to the operations.
mySubtractOperation->Messages->Add( myOperationInputMessage2 );
mySubtractOperation->Messages->Add( myOperationOutputMessage2 );
// Add the operations to the PortType.
myPortType->Operations->Add( myAddOperation );
myPortType->Operations->Add( mySubtractOperation );
// Add the PortType to the collection.
myServiceDescription->PortTypes->Add( myPortType );
}
}
public static void MyMethod(
ServiceDescriptionBaseCollection myServiceCollection)
{
Type myType = myServiceCollection.GetType();
if (myType.Equals(
typeof(System.Web.Services.Description.ServiceCollection)))
{
// Remove the services at index 0 of the collection.
((ServiceCollection)myServiceCollection).Remove(
myServiceDescription.Services[0]);
// Build a new Service.
Service myService =new Service();
myService.Name="MathService";
XmlQualifiedName myXmlQualifiedName =
new XmlQualifiedName("s0:MathServiceSoap");
// Build a new Port for SOAP.
Port mySoapPort= new Port();
mySoapPort.Name="MathServiceSoap";
mySoapPort.Binding=myXmlQualifiedName;
SoapAddressBinding mySoapAddressBinding = new SoapAddressBinding();
mySoapAddressBinding.Location = "http://localhost/" +
"ServiceDescriptionBaseCollection/AddSubtractService.CS.asmx";
mySoapPort.Extensions.Add(mySoapAddressBinding);
// Build a new Port for HTTP-GET.
XmlQualifiedName myXmlQualifiedName2 =
new XmlQualifiedName("s0:MathServiceHttpGet");
Port myHttpGetPort= new Port();
myHttpGetPort.Name="MathServiceHttpGet";
myHttpGetPort.Binding=myXmlQualifiedName2;
HttpAddressBinding myHttpAddressBinding = new HttpAddressBinding();
myHttpAddressBinding.Location = "http://localhost/" +
"ServiceDescriptionBaseCollection/AddSubtractService.CS.asmx";
myHttpGetPort.Extensions.Add(myHttpAddressBinding);
// Add the ports to the Service.
myService.Ports.Add(myHttpGetPort);
myService.Ports.Add(mySoapPort);
// Add the Service to the ServiceCollection.
myServiceDescription.Services.Add(myService);
}
else if(myType.Equals(
typeof(System.Web.Services.Description.BindingCollection)))
{
// Remove the Binding in the BindingCollection at index 0.
((BindingCollection)myServiceCollection).Remove(
myServiceDescription.Bindings[0]);
// Build a new Binding.
Binding myBinding = new Binding();
myBinding.Name = "MathServiceSoap";
XmlQualifiedName myXmlQualifiedName =
new XmlQualifiedName("s0:MathServiceSoap");
myBinding.Type=myXmlQualifiedName;
SoapBinding mySoapBinding = new SoapBinding();
mySoapBinding.Transport = "http://schemas.xmlsoap.org/soap/http";
mySoapBinding.Style = SoapBindingStyle.Document;
// Create the operations for the binding.
OperationBinding addOperationBinding = CreateOperationBinding(
"Add", myServiceDescription.TargetNamespace);
OperationBinding subtractOperationBinding = CreateOperationBinding(
"Subtract",myServiceDescription.TargetNamespace);
// Add the operations to the Binding.
myBinding.Operations.Add(subtractOperationBinding);
myBinding.Operations.Add(addOperationBinding);
myBinding.Extensions.Add(mySoapBinding);
// Add the Binding to the Bindings collection.
myServiceDescription.Bindings.Add(myBinding);
}
else if (myType.Equals(
typeof(System.Web.Services.Description.PortTypeCollection)))
{
// Remove the PortType at index 0.
((PortTypeCollection)myServiceCollection).Remove(
myServiceDescription.PortTypes[0]);
// Build a new PortType.
PortType myPortType = new PortType();
myPortType.Name = "MathServiceSoap";
// Build an Add Operation for the PortType.
Operation myAddOperation = new Operation();
myAddOperation.Name="Add";
// Build the Input and Output messages for the Operations.
OperationInput myOperationInputMessage1 = new OperationInput();
XmlQualifiedName myXmlQualifiedName1 =
new XmlQualifiedName("s0:AddSoapIn");
myOperationInputMessage1.Message = myXmlQualifiedName1;
OperationOutput myOperationOutputMessage1 = new OperationOutput();
XmlQualifiedName myXmlQualifiedName2 =
new XmlQualifiedName("s0:AddSoapOut");
myOperationOutputMessage1.Message=myXmlQualifiedName2;
// Add the messages to the operations.
myAddOperation.Messages.Add(myOperationInputMessage1);
myAddOperation.Messages.Add(myOperationOutputMessage1);
// Build an Add Operation for the PortType.
Operation mySubtractOperation = new Operation();
mySubtractOperation.Name = "Subtract";
// Build the Input and Output messages for the operations.
OperationInput myOperationInputMessage2 = new OperationInput();
XmlQualifiedName myXmlQualifiedName3 =
new XmlQualifiedName("s0:SubtractSoapIn");
myOperationInputMessage2.Message = myXmlQualifiedName3;
OperationOutput myOperationOutputMessage2 = new OperationOutput();
XmlQualifiedName myXmlQualifiedName4 =
new XmlQualifiedName("s0:SubtractSoapOut");
myOperationOutputMessage2.Message = myXmlQualifiedName4;
// Add the messages to the operations.
mySubtractOperation.Messages.Add(myOperationInputMessage2);
mySubtractOperation.Messages.Add(myOperationOutputMessage2);
// Add the operations to the PortType.
myPortType.Operations.Add(myAddOperation);
myPortType.Operations.Add(mySubtractOperation);
// Add the PortType to the collection.
myServiceDescription.PortTypes.Add(myPortType);
}
}
Public Shared Sub MyMethod(myServiceCollection As _
ServiceDescriptionBaseCollection)
Dim myType As Type = myServiceCollection.GetType()
If myType.Equals( _
GetType(System.Web.Services.Description.ServiceCollection)) Then
' Remove the services at index 0 of the collection.
CType(myServiceCollection, ServiceCollection).Remove( _
myServiceDescription.Services(0))
' Build a new Service.
Dim myService As New Service()
myService.Name = "MathService"
Dim myXmlQualifiedName As _
New XmlQualifiedName("s0:MathServiceSoap")
' Build a new Port for SOAP.
Dim mySoapPort As New Port()
mySoapPort.Name = "MathServiceSoap"
mySoapPort.Binding = myXmlQualifiedName
Dim mySoapAddressBinding As New SoapAddressBinding()
mySoapAddressBinding.Location = "http://localhost/" & _
"ServiceDescriptionBaseCollection_VB/AddSubtractService.VB.asmx"
mySoapPort.Extensions.Add(mySoapAddressBinding)
' Build a new Port for HTTP-GET.
Dim myXmlQualifiedName2 As _
New XmlQualifiedName("s0:MathServiceHttpGet")
Dim myHttpGetPort As New Port()
myHttpGetPort.Name = "MathServiceHttpGet"
myHttpGetPort.Binding = myXmlQualifiedName2
Dim myHttpAddressBinding As New HttpAddressBinding()
myHttpAddressBinding.Location = "http://localhost/" & _
"ServiceDescriptionBaseCollection_VB/AddSubtractService.VB.asmx"
myHttpGetPort.Extensions.Add(myHttpAddressBinding)
' Add the ports to the Service.
myService.Ports.Add(myHttpGetPort)
myService.Ports.Add(mySoapPort)
' Add the Service to the ServiceCollection.
myServiceDescription.Services.Add(myService)
Else
If myType.Equals( _
GetType(System.Web.Services.Description.BindingCollection)) Then
' Remove the Binding in the BindingCollection at index 0.
CType(myServiceCollection, BindingCollection).Remove( _
myServiceDescription.Bindings(0))
' Build a new Binding.
Dim myBinding As New Binding()
myBinding.Name = "MathServiceSoap"
Dim myXmlQualifiedName As _
New XmlQualifiedName("s0:MathServiceSoap")
myBinding.Type = myXmlQualifiedName
Dim mySoapBinding As New SoapBinding()
mySoapBinding.Transport = "http://schemas.xmlsoap.org/soap/http"
mySoapBinding.Style = SoapBindingStyle.Document
' Create the operations for the binding.
Dim addOperationBinding As OperationBinding = _
CreateOperationBinding("Add", _
myServiceDescription.TargetNamespace)
Dim subtractOperationBinding As OperationBinding = _
CreateOperationBinding("Subtract", _
myServiceDescription.TargetNamespace)
' Add the operations to the Binding.
myBinding.Operations.Add(subtractOperationBinding)
myBinding.Operations.Add(addOperationBinding)
myBinding.Extensions.Add(mySoapBinding)
' Add the Binding to the Bindings collection.
myServiceDescription.Bindings.Add(myBinding)
Else
If myType.Equals( _
GetType(System.Web.Services.Description.PortTypeCollection)) Then
' Remove the PortType at index 0.
CType(myServiceCollection, PortTypeCollection).Remove( _
myServiceDescription.PortTypes(0))
' Build a new PortType.
Dim myPortType As New PortType()
myPortType.Name = "MathServiceSoap"
' Build an AddOperation for the PortType.
Dim myAddOperation As New Operation()
myAddOperation.Name = "Add"
' Build the Input and Output messages for the Operations.
Dim myOperationInputMessage1 As New OperationInput()
Dim myXmlQualifiedName1 As New XmlQualifiedName("s0:AddSoapIn")
myOperationInputMessage1.Message = myXmlQualifiedName1
Dim myOperationOutputMessage1 As New OperationOutput()
Dim myXmlQualifiedName2 As New XmlQualifiedName("s0:AddSoapOut")
myOperationOutputMessage1.Message = myXmlQualifiedName2
' Add the messages to the operations.
myAddOperation.Messages.Add(myOperationInputMessage1)
myAddOperation.Messages.Add(myOperationOutputMessage1)
' Build an Add Operation for the PortType.
Dim mySubtractOperation As New Operation()
mySubtractOperation.Name = "Subtract"
' Build the Input and Output messages for the operations.
Dim myOperationInputMessage2 As New OperationInput()
Dim myXmlQualifiedName3 As _
New XmlQualifiedName("s0:SubtractSoapIn")
myOperationInputMessage2.Message = myXmlQualifiedName3
Dim myOperationOutputMessage2 As New OperationOutput()
Dim myXmlQualifiedName4 As _
New XmlQualifiedName("s0:SubtractSoapOut")
myOperationOutputMessage2.Message = myXmlQualifiedName4
' Add the messages to the operations.
mySubtractOperation.Messages.Add(myOperationInputMessage2)
mySubtractOperation.Messages.Add(myOperationOutputMessage2)
' Add the operations to the PortType.
myPortType.Operations.Add(myAddOperation)
myPortType.Operations.Add(mySubtractOperation)
' Add the PortType to the collection.
myServiceDescription.PortTypes.Add(myPortType)
End If
End If
End If
End Sub
属性
Capacity |
获取或设置 CollectionBase 可包含的元素数。Gets or sets the number of elements that the CollectionBase can contain. (继承自 CollectionBase) |
Count |
获取 CollectionBase 实例中包含的元素数。Gets the number of elements contained in the CollectionBase instance. 不能重写此属性。This property cannot be overridden. (继承自 CollectionBase) |
InnerList |
获取一个 ArrayList,它包含 CollectionBase 实例中元素的列表。Gets an ArrayList containing the list of elements in the CollectionBase instance. (继承自 CollectionBase) |
List |
获取一个 IList,它包含 CollectionBase 实例中元素的列表。Gets an IList containing the list of elements in the CollectionBase instance. (继承自 CollectionBase) |
Table |
获取实现 ServiceDescriptionBaseCollection 中键和值的关联的接口。Gets an interface that implements the association of the keys and values in the ServiceDescriptionBaseCollection. |
方法
Clear() |
从 CollectionBase 实例移除所有对象。Removes all objects from the CollectionBase instance. 不能重写此方法。This method cannot be overridden. (继承自 CollectionBase) |
Equals(Object) |
确定指定对象是否等于当前对象。Determines whether the specified object is equal to the current object. (继承自 Object) |
GetEnumerator() |
返回循环访问 CollectionBase 实例的枚举器。Returns an enumerator that iterates through the CollectionBase instance. (继承自 CollectionBase) |
GetHashCode() |
作为默认哈希函数。Serves as the default hash function. (继承自 Object) |
GetKey(Object) |
返回与通过引用传递的值关联的键的名称。Returns the name of the key associated with the value passed by reference. |
GetType() |
获取当前实例的 Type。Gets the Type of the current instance. (继承自 Object) |
MemberwiseClone() |
创建当前 Object 的浅表副本。Creates a shallow copy of the current Object. (继承自 Object) |
OnClear() |
清除 ServiceDescriptionBaseCollection 实例的内容。Clears the contents of the ServiceDescriptionBaseCollection instance. |
OnClearComplete() |
在清除 CollectionBase 实例的内容之后执行其他自定义进程。Performs additional custom processes after clearing the contents of the CollectionBase instance. (继承自 CollectionBase) |
OnInsert(Int32, Object) |
在向 CollectionBase 实例中插入新元素之前执行其他自定义进程。Performs additional custom processes before inserting a new element into the CollectionBase instance. (继承自 CollectionBase) |
OnInsertComplete(Int32, Object) |
将新元素插入 ServiceDescriptionBaseCollection 后,执行附加的自定义进程。Performs additional custom processes after inserting a new element into the ServiceDescriptionBaseCollection. |
OnRemove(Int32, Object) |
从 ServiceDescriptionBaseCollection 中移除一个元素。Removes an element from the ServiceDescriptionBaseCollection. |
OnRemoveComplete(Int32, Object) |
在从 CollectionBase 实例中移除元素之后执行其他自定义进程。Performs additional custom processes after removing an element from the CollectionBase instance. (继承自 CollectionBase) |
OnSet(Int32, Object, Object) |
用 ServiceDescriptionBaseCollection 中的一个值替换另一个值。Replaces one value with another within the ServiceDescriptionBaseCollection. |
OnSetComplete(Int32, Object, Object) |
当在 CollectionBase 实例中设置值后执行其他自定义进程。Performs additional custom processes after setting a value in the CollectionBase instance. (继承自 CollectionBase) |
OnValidate(Object) |
当验证值时执行其他自定义进程。Performs additional custom processes when validating a value. (继承自 CollectionBase) |
RemoveAt(Int32) |
移除 CollectionBase 实例的指定索引处的元素。Removes the element at the specified index of the CollectionBase instance. 此方法不可重写。This method is not overridable. (继承自 CollectionBase) |
SetParent(Object, Object) |
设置 ServiceDescriptionBaseCollection 实例的父对象。Sets the parent object of the ServiceDescriptionBaseCollection instance. |
ToString() |
返回表示当前对象的字符串。Returns a string that represents the current object. (继承自 Object) |
显式接口实现
ICollection.CopyTo(Array, Int32) |
从目标数组的指定索引处开始将整个 CollectionBase 复制到兼容的一维 Array。Copies the entire CollectionBase to a compatible one-dimensional Array, starting at the specified index of the target array. (继承自 CollectionBase) |
ICollection.IsSynchronized |
获取一个值,该值指示是否同步对 CollectionBase 的访问(线程安全)。Gets a value indicating whether access to the CollectionBase is synchronized (thread safe). (继承自 CollectionBase) |
ICollection.SyncRoot |
获取可用于同步对 CollectionBase 的访问的对象。Gets an object that can be used to synchronize access to the CollectionBase. (继承自 CollectionBase) |
IList.Add(Object) |
将对象添加到 CollectionBase 的结尾处。Adds an object to the end of the CollectionBase. (继承自 CollectionBase) |
IList.Contains(Object) |
确定 CollectionBase 是否包含特定元素。Determines whether the CollectionBase contains a specific element. (继承自 CollectionBase) |
IList.IndexOf(Object) |
搜索指定的 Object,并返回整个 CollectionBase 中第一个匹配项的从零开始的索引。Searches for the specified Object and returns the zero-based index of the first occurrence within the entire CollectionBase. (继承自 CollectionBase) |
IList.Insert(Int32, Object) |
将元素插入 CollectionBase 的指定索引处。Inserts an element into the CollectionBase at the specified index. (继承自 CollectionBase) |
IList.IsFixedSize |
获取一个值,该值指示 CollectionBase 是否具有固定大小。Gets a value indicating whether the CollectionBase has a fixed size. (继承自 CollectionBase) |
IList.IsReadOnly |
获取一个值,该值指示 CollectionBase 是否为只读。Gets a value indicating whether the CollectionBase is read-only. (继承自 CollectionBase) |
IList.Item[Int32] |
获取或设置指定索引处的元素。Gets or sets the element at the specified index. (继承自 CollectionBase) |
IList.Remove(Object) |
从 CollectionBase 中移除特定对象的第一个匹配项。Removes the first occurrence of a specific object from the CollectionBase. (继承自 CollectionBase) |
扩展方法
Cast<TResult>(IEnumerable) |
将 IEnumerable 的元素强制转换为指定的类型。Casts the elements of an IEnumerable to the specified type. |
OfType<TResult>(IEnumerable) |
根据指定类型筛选 IEnumerable 的元素。Filters the elements of an IEnumerable based on a specified type. |
AsParallel(IEnumerable) |
启用查询的并行化。Enables parallelization of a query. |
AsQueryable(IEnumerable) |
将 IEnumerable 转换为 IQueryable。Converts an IEnumerable to an IQueryable. |