Udostępnij za pośrednictwem


BindingCollection.Insert(Int32, Binding) Metoda

Definicja

Dodaje określony Binding element do określonego BindingCollection indeksu opartego na zera.

public:
 void Insert(int index, System::Web::Services::Description::Binding ^ binding);
public void Insert (int index, System.Web.Services.Description.Binding binding);
member this.Insert : int * System.Web.Services.Description.Binding -> unit
Public Sub Insert (index As Integer, binding As Binding)

Parametry

index
Int32

Indeks oparty na zera, w którym ma być wstawiony binding parametr.

binding
Binding

Element Binding do dodania do kolekcji.

Przykłady

// Create a new Binding for SOAP Protocol.
Binding^ myBinding = gcnew Binding;
myBinding->Name = String::Concat( myServiceDescription->Services->default[ 0 ]->Name, "Soap" );

// Pass the name of the existing porttype 'MathServiceSoap' and the Xml targetNamespace attribute of the Descriptions tag.
myBinding->Type = gcnew XmlQualifiedName( "MathServiceSoap",myServiceDescription->TargetNamespace );

// Create SOAP Extensibility element.
SoapBinding^ mySoapBinding = gcnew SoapBinding;
// SOAP over HTTP.
mySoapBinding->Transport = "http://schemas.xmlsoap.org/soap/http";
mySoapBinding->Style = SoapBindingStyle::Document;
// Add tag soap:binding as an extensibility element.
myBinding->Extensions->Add( mySoapBinding );

// Create OperationBindings for each of the operations defined in asmx file.
OperationBinding^ addOperationBinding = CreateOperationBinding( "Add", myServiceDescription->TargetNamespace );
myBinding->Operations->Add( addOperationBinding );
OperationBinding^ subtractOperationBinding = CreateOperationBinding( "Subtract", myServiceDescription->TargetNamespace );
myBinding->Operations->Add( subtractOperationBinding );
OperationBinding^ multiplyOperationBinding = CreateOperationBinding( "Multiply", myServiceDescription->TargetNamespace );
myBinding->Operations->Add( multiplyOperationBinding );
OperationBinding^ divideOperationBinding = CreateOperationBinding( "Divide", myServiceDescription->TargetNamespace );
myBinding->Operations->Add( divideOperationBinding );

myServiceDescription->Bindings->Insert( 0, myBinding );
// Create a new Binding for SOAP Protocol.
Binding myBinding = new Binding();
myBinding.Name = myServiceDescription.Services[0].Name + "Soap";
// Pass the name of the existing porttype 'MathServiceSoap' and the Xml targetNamespace attribute of the Descriptions tag.
myBinding.Type = new XmlQualifiedName("MathServiceSoap",myServiceDescription.TargetNamespace);
// Create SOAP Extensibility element.
SoapBinding mySoapBinding = new SoapBinding();
// SOAP over HTTP.
mySoapBinding.Transport = "http://schemas.xmlsoap.org/soap/http";
mySoapBinding.Style = SoapBindingStyle.Document;
// Add tag soap:binding as an extensibility element.
myBinding.Extensions.Add(mySoapBinding);
// Create OperationBindings for each of the operations defined in asmx file.
OperationBinding addOperationBinding = CreateOperationBinding("Add",myServiceDescription.TargetNamespace);
myBinding.Operations.Add(addOperationBinding);
OperationBinding subtractOperationBinding = CreateOperationBinding("Subtract",myServiceDescription.TargetNamespace);
myBinding.Operations.Add(subtractOperationBinding);
OperationBinding multiplyOperationBinding = CreateOperationBinding("Multiply",myServiceDescription.TargetNamespace);
myBinding.Operations.Add(multiplyOperationBinding);
OperationBinding divideOperationBinding = CreateOperationBinding("Divide",myServiceDescription.TargetNamespace);
myBinding.Operations.Add(divideOperationBinding);
myServiceDescription.Bindings.Insert(0,myBinding);
' Create a new Binding for SOAP Protocol.
Dim myBinding As New Binding()
myBinding.Name = myServiceDescription.Services(0).Name + "Soap"
' Pass the name of the existing porttype 'MathServiceSoap' and the Xml targetNamespace attribute of the Descriptions tag.
myBinding.Type = New XmlQualifiedName("MathServiceSoap", myServiceDescription.TargetNamespace)
' Create SOAP Extensibility element.
Dim mySoapBinding As New SoapBinding()
' SOAP over Http.

mySoapBinding.Transport = "http://schemas.xmlsoap.org/soap/http"
mySoapBinding.Style = SoapBindingStyle.Document
' Add tag soap:binding as an extensibility element.
myBinding.Extensions.Add(mySoapBinding)
' Create OperationBindings for each of the operations defined in asmx file.
Dim addOperationBinding As OperationBinding = CreateOperationBinding("Add", myServiceDescription.TargetNamespace)
myBinding.Operations.Add(addOperationBinding)
Dim subtractOperationBinding As OperationBinding = CreateOperationBinding("Subtract", myServiceDescription.TargetNamespace)
myBinding.Operations.Add(subtractOperationBinding)
Dim multiplyOperationBinding As OperationBinding = CreateOperationBinding("Multiply", myServiceDescription.TargetNamespace)
myBinding.Operations.Add(multiplyOperationBinding)
Dim divideOperationBinding As OperationBinding = CreateOperationBinding("Divide", myServiceDescription.TargetNamespace)
myBinding.Operations.Add(divideOperationBinding)
myServiceDescription.Bindings.Insert(0, myBinding)

Uwagi

Jeśli liczba elementów w kolekcji jest już równa pojemności kolekcji, pojemność jest podwojona przez automatyczne cofnięcie przydziału tablicy wewnętrznej przed wstawieniem nowego elementu.

index Jeśli parametr jest równy Count, binding parametr zostanie dodany na końcu BindingCollection.

Elementy po przejściu punktu wstawiania w dół, aby pomieścić nowy element.

Dotyczy