Freigeben über


ServiceCollection.Insert-Methode

Fügt der ServiceCollection die angegebene Service-Instanz am angegebenen nullbasierten Index hinzu.

Namespace: System.Web.Services.Description
Assembly: System.Web.Services (in system.web.services.dll)

Syntax

'Declaration
Public Sub Insert ( _
    index As Integer, _
    service As Service _
)
'Usage
Dim instance As ServiceCollection
Dim index As Integer
Dim service As Service

instance.Insert(index, service)
public void Insert (
    int index,
    Service service
)
public:
void Insert (
    int index, 
    Service^ service
)
public void Insert (
    int index, 
    Service service
)
public function Insert (
    index : int, 
    service : Service
)

Parameter

  • index
    Der nullbasierte Index, an dem der service-Parameter eingefügt werden soll.
  • service
    Der der Auflistung hinzuzufügende Service.

Ausnahmen

Ausnahmetyp Bedingung

IndexOutOfRangeException

Der index-Parameter ist kleiner als 0.

– oder –

Der index-Parameter ist größer als Count.

Hinweise

Wenn die Anzahl der Elemente in der Auflistung bereits der Kapazität der Auflistung entspricht, wird diese verdoppelt, indem das interne Array vor dem Einfügen des neuen Elements automatisch neu reserviert wird.

Wenn der Wert des index-Parameters gleich Count ist, wird am Ende der ServiceCollection der service-Parameter hinzugefügt.

Die Elemente nach der Einfügemarke werden nach unten verschoben, um das neue Element aufnehmen zu können.

Beispiel

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)
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);
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 = "https://localhost/ServiceDescription_Read/AddService_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 = "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 );
Service myService = new Service();
myService.set_Name("MathService");
XmlQualifiedName myXmlQualifiedName = 
    new XmlQualifiedName("s0:MathServiceSoap");

// Build a new Port for SOAP.
Port mySoapPort = new Port();
mySoapPort.set_Name("MathServiceSoap");
mySoapPort.set_Binding(myXmlQualifiedName);
SoapAddressBinding mySoapAddressBinding = new SoapAddressBinding();
mySoapAddressBinding.set_Location(
    "https://localhost/ServiceDescription_Read/AddService_JSL.asmx");
mySoapPort.get_Extensions().Add(mySoapAddressBinding);

// Build a new Port for HTTP-GET.
XmlQualifiedName myXmlQualifiedName2 = 
    new XmlQualifiedName("s0:MathServiceHttpGet");
Port myHttpGetPort = new Port();
myHttpGetPort.set_Name("MathServiceHttpGet");
myHttpGetPort.set_Binding(myXmlQualifiedName2);
HttpAddressBinding myHttpAddressBinding = new HttpAddressBinding();
myHttpAddressBinding.set_Location(
    "https://localhost/ServiceDescription_Read/AddService_JSL.asmx");
myHttpGetPort.get_Extensions().Add(myHttpAddressBinding);

// Add the ports to the service.
myService.get_Ports().Add(myHttpGetPort);
myService.get_Ports().Add(mySoapPort);

// Add the service to the ServiceCollection.
myServiceDescription.get_Services().Insert(1, myService);

Plattformen

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.

Versionsinformationen

.NET Framework

Unterstützt in: 2.0, 1.1, 1.0

Siehe auch

Referenz

ServiceCollection-Klasse
ServiceCollection-Member
System.Web.Services.Description-Namespace