Partilhar via


BindingCollection.Insert(Int32, Binding) Método

Definição

Adiciona o Binding especificado ao BindingCollection no índice de base zero especificado.

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)

Parâmetros

index
Int32

O índice de base zero no qual inserir o parâmetro binding.

binding
Binding

A Binding a ser adicionada à coleção.

Exemplos

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

Comentários

Se o número de itens na coleção já for igual à capacidade da coleção, a capacidade será dobrada realocando automaticamente a matriz interna antes que o novo elemento seja inserido.

Se o index parâmetro for igual a Count, o binding parâmetro será adicionado ao final do BindingCollection.

Os elementos após o ponto de inserção são movidos para baixo para acomodar o novo elemento.

Aplica-se a