ServiceCollection.Insert メソッド
指定した 0 から始まるインデックス番号にある ServiceCollection に、指定した Service インスタンスを追加します。
Public Sub Insert( _
ByVal index As Integer, _ ByVal service As Service _)
[C#]
public void Insert(intindex,Serviceservice);
[C++]
public: void Insert(intindex,Service* service);
[JScript]
public function Insert(
index : int,service : Service);
パラメータ
- index
service パラメータを挿入する位置の、0 から始まるインデックス番号。 - service
コレクションに追加する Service 。
例外
例外の種類 | 条件 |
---|---|
IndexOutOfRangeException | index パラメータが 0 未満です。
または index パラメータが Count より大きい値です。 |
解説
コレクション内の項目数が既にコレクションの許容量に達している場合は、新しい要素が挿入される前に内部配列が自動的に再割り当てされ、コレクションの容量が 2 倍になります。
index パラメータの値と Count が等しい場合は、 service パラメータが ServiceCollection の末尾に追加されます。
新しい要素を挿入できるように、挿入位置より後にある要素の位置が繰り下がります。
使用例
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 = _
"https://localhost/ServiceDescription_Read/AddService_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 = _
"https://localhost/ServiceDescription_Read/AddService_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.Insert(1, myService)
[C#]
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 =
"https://localhost/ServiceDescription_Read/AddService_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 =
"https://localhost/ServiceDescription_Read/AddService_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.Insert(1,myService);
[C++]
Service* myService = new Service();
myService->Name = S"MathService";
XmlQualifiedName* myXmlQualifiedName =
new XmlQualifiedName(S"s0:MathServiceSoap");
// Build a new Port for SOAP.
Port* mySoapPort = new Port();
mySoapPort->Name = S"MathServiceSoap";
mySoapPort->Binding = myXmlQualifiedName;
SoapAddressBinding* mySoapAddressBinding = new SoapAddressBinding();
mySoapAddressBinding->Location =
S"https://localhost/ServiceDescription_Read/AddService_CS.asmx";
mySoapPort->Extensions->Add(mySoapAddressBinding);
// Build a new Port for HTTP-GET.
XmlQualifiedName* myXmlQualifiedName2 =
new XmlQualifiedName(S"s0:MathServiceHttpGet");
Port* myHttpGetPort = new Port();
myHttpGetPort->Name = S"MathServiceHttpGet";
myHttpGetPort->Binding = myXmlQualifiedName2;
HttpAddressBinding* myHttpAddressBinding = new HttpAddressBinding();
myHttpAddressBinding->Location =
S"https://localhost/ServiceDescription_Read/AddService_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->Insert(1,myService);
[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン をクリックします。
必要条件
プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ
参照
ServiceCollection クラス | ServiceCollection メンバ | System.Web.Services.Description 名前空間