FaultBindingCollection.CopyTo メソッド

FaultBindingCollection 全体を互換性のある FaultBinding 型の 1 次元配列にコピーします。コピーは、コピー先の配列の、指定した 0 から始まるインデックス番号から開始します。

Public Sub CopyTo( _
   ByVal array() As FaultBinding, _   ByVal index As Integer _)
[C#]
public void CopyTo(FaultBinding[] array,intindex);
[C++]
public: void CopyTo(FaultBinding* array[],intindex);
[JScript]
public function CopyTo(
   array : FaultBinding[],index : int);

パラメータ

  • array
    コピー アクションのコピー先として使用する FaultBinding 型の配列。
  • index
    コピーされたコレクションの貼り付け開始位置を示す、0 から始まるインデックス番号。

使用例

[Visual Basic, C#, C++] CopyTo メソッドの一般的な使用例を次に示します。

 
Dim myBindingCollection As BindingCollection = myServiceDescription.Bindings
Dim myBinding As Binding = myBindingCollection(0)
Dim myOperationBindingCollection As OperationBindingCollection = myBinding.Operations
Dim myOperationBinding As OperationBinding = myOperationBindingCollection(0)
Dim myFaultBindingCollection As FaultBindingCollection = myOperationBinding.Faults

' Reverse the fault bindings order.
If myFaultBindingCollection.Count > 1 Then
   Dim myFaultBinding As FaultBinding = myFaultBindingCollection(0)

   Dim myFaultBindingArray(myFaultBindingCollection.Count - 1) As FaultBinding
   ' Copy the fault bindings to a temporary array.
   myFaultBindingCollection.CopyTo(myFaultBindingArray, 0)

   ' Remove all the fault binding instances in the fault binding collection.
   Dim i, j As Integer

   For i = 0 To myFaultBindingArray.Length - 1
      myFaultBindingCollection.Remove(myFaultBindingArray(i))
   Next i

   j = myFaultBindingArray.Length - 1
   For i = 0 To myFaultBindingArray.Length - 1
      myFaultBindingCollection.Insert(i, myFaultBindingArray(j))
      j = j - 1
   Next

   If myFaultBindingCollection.Contains(myFaultBinding) And myFaultBindingCollection.IndexOf(myFaultBinding) = myFaultBindingCollection.Count - 1 Then
      ' Display the WSDL generated to the console.
      myServiceDescription.Write(Console.Out)
   Else
      Console.WriteLine("Error while reversing")
   End If
End If
   End Sub 'Main 

End Class 'FaultBindingCollection_Remove

[C#] 

      BindingCollection myBindingCollection = myServiceDescription.Bindings;
      Binding myBinding = myBindingCollection[0];
      OperationBindingCollection myOperationBindingCollection = myBinding.Operations;
      OperationBinding myOperationBinding = myOperationBindingCollection[0];
      FaultBindingCollection myFaultBindingCollection = myOperationBinding.Faults;

      // Reverse the fault bindings order.
      if(myFaultBindingCollection.Count > 1) 
      {
         FaultBinding myFaultBinding = myFaultBindingCollection[0];

         FaultBinding[] myFaultBindingArray = new FaultBinding[myFaultBindingCollection.Count];
         // Copy the fault bindings to a temporary array.
         myFaultBindingCollection.CopyTo(myFaultBindingArray, 0);

         // Remove all the fault binding instances in the fault binding collection.
         for(int i = 0; i < myFaultBindingArray.Length; i++)
            myFaultBindingCollection.Remove(myFaultBindingArray[i]);

         // Insert the fault binding instance in the reverse order.
         for(int i = 0, j = (myFaultBindingArray.Length - 1); i < myFaultBindingArray.Length; i++, j--)
            myFaultBindingCollection.Insert(i, myFaultBindingArray[j]);
         // Check if the first element in the collection before the reversal is now the last element.
         if(myFaultBindingCollection.Contains(myFaultBinding) && 
            myFaultBindingCollection.IndexOf(myFaultBinding) == (myFaultBindingCollection.Count - 1))
            // Display the WSDL generated to the console.
            myServiceDescription.Write(Console.Out);
         else
            Console.WriteLine("Error while reversing");
      }


[C++] 

   BindingCollection * myBindingCollection = myServiceDescription->Bindings;
   Binding * myBinding = myBindingCollection->Item[0];
   OperationBindingCollection * myOperationBindingCollection = myBinding->Operations;
   OperationBinding * myOperationBinding = myOperationBindingCollection->Item[0];
   FaultBindingCollection * myFaultBindingCollection = myOperationBinding->Faults;

   // Reverse the fault bindings order.
   if (myFaultBindingCollection->Count > 1)
   {
      FaultBinding * myFaultBinding = myFaultBindingCollection->Item[0];

      FaultBinding* myFaultBindingArray[] = new FaultBinding*[myFaultBindingCollection->Count];
      // Copy the fault bindings to a temporary array.
      myFaultBindingCollection->CopyTo(myFaultBindingArray, 0);

      // Remove all the fault binding instances in the fault binding collection.
      for (int i = 0; i < myFaultBindingArray->Length; i++)
         myFaultBindingCollection->Remove(myFaultBindingArray->Item[i]);

      // Insert the fault binding instance in the reverse order.
      for (int i = 0, j = (myFaultBindingArray->Length - 1); i < myFaultBindingArray->Length; i++, j--)
         myFaultBindingCollection->Insert(i, myFaultBindingArray->Item[j]);

      // Check if the first element in the collection before the reversal is now the last element.
      if (myFaultBindingCollection->Contains(myFaultBinding) && 
         myFaultBindingCollection->IndexOf(myFaultBinding) == (myFaultBindingCollection->Count - 1))

         // Display the WSDL generated to the console.
         myServiceDescription->Write(Console::Out);
      else
         Console::WriteLine(S"Error while reversing");
   }

[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 ファミリ

参照

FaultBindingCollection クラス | FaultBindingCollection メンバ | System.Web.Services.Description 名前空間