Condividi tramite


BindingCollection.Insert(Int32, Binding) Metodo

Definizione

Aggiunge l'oggetto Binding specificato a BindingCollection in corrispondenza dell'indice in base zero specificato.

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)

Parametri

index
Int32

Indice a base zero in corrispondenza del quale inserire il parametro binding.

binding
Binding

Oggetto Binding da aggiungere all'insieme.

Esempio

// 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)

Commenti

Se il numero di elementi nella raccolta è già uguale alla capacità della raccolta, la capacità viene raddoppiata riallocazione automatica della matrice interna prima dell'inserimento del nuovo elemento.

Se il index parametro è uguale a Count, il binding parametro viene aggiunto alla fine di BindingCollection.

Gli elementi dopo il punto di inserimento si spostano verso il basso per contenere il nuovo elemento.

Si applica a