共用方式為


ServiceDescriptionFormatExtensionCollection 類別

定義

表示 XML Web 服務所使用擴充性項目的集合。 此類別無法獲得繼承。

public ref class ServiceDescriptionFormatExtensionCollection sealed : System::Web::Services::Description::ServiceDescriptionBaseCollection
public sealed class ServiceDescriptionFormatExtensionCollection : System.Web.Services.Description.ServiceDescriptionBaseCollection
type ServiceDescriptionFormatExtensionCollection = class
    inherit ServiceDescriptionBaseCollection
Public NotInheritable Class ServiceDescriptionFormatExtensionCollection
Inherits ServiceDescriptionBaseCollection
繼承
ServiceDescriptionFormatExtensionCollection

範例

#using <System.Web.Services.dll>
#using <System.Xml.dll>

using namespace System;
using namespace System::Web::Services::Description;
using namespace System::Collections;

ref class MyFormatExtension: public ServiceDescriptionFormatExtension
{
public:
   MyFormatExtension()
   {
      // Set the properties.
      this->Handled = true;
      this->Required = true;
   }
};

int main()
{
   try
   {
      ServiceDescription^ myServiceDescription = ServiceDescription::Read( "Sample_cpp.wsdl" );
      ServiceDescriptionFormatExtensionCollection^ myCollection = gcnew ServiceDescriptionFormatExtensionCollection( myServiceDescription );

      SoapBinding^ mySoapBinding1 = gcnew SoapBinding;
      SoapBinding^ mySoapBinding2 = gcnew SoapBinding;
      SoapAddressBinding^ mySoapAddressBinding = gcnew SoapAddressBinding;
      MyFormatExtension^ myFormatExtensionObject = gcnew MyFormatExtension;

      // Add elements to collection.
      myCollection->Add( mySoapBinding1 );
      myCollection->Add( mySoapAddressBinding );
      myCollection->Add( mySoapBinding2 );
      myCollection->Add( myFormatExtensionObject );

      Console::WriteLine( "Collection contains following types of elements: " );
      
      // Display the 'Type' of the elements in collection.
      for ( int i = 0; i < myCollection->Count; i++ )
         Console::WriteLine( myCollection[ i ]->GetType() );

      // Check element of type 'SoapAddressBinding' in collection.
      Object^ myObj = myCollection->Find( mySoapAddressBinding->GetType() );
      if ( myObj == nullptr )
            Console::WriteLine( "Element of type ' {0}' not found in collection.", mySoapAddressBinding->GetType() );
      else
            Console::WriteLine( "Element of type ' {0}' found in collection.", mySoapAddressBinding->GetType() );

      // Check all elements of type 'SoapBinding' in collection.
      array<Object^>^myObjectArray1 = gcnew array<Object^>(myCollection->Count);
      myObjectArray1 = myCollection->FindAll( mySoapBinding1->GetType() );
      int myNumberOfElements = 0;
      IEnumerator^ myIEnumerator = myObjectArray1->GetEnumerator();

      // Calculate number of elements of type 'SoapBinding'.
      while ( myIEnumerator->MoveNext() )
            if ( mySoapBinding1->GetType() == myIEnumerator->Current->GetType() )
            myNumberOfElements++;
      Console::WriteLine( "Collection contains {0} objects of type ' {1}'.", myNumberOfElements, mySoapBinding1->GetType() );

      // Check 'IsHandled' status for 'myFormatExtensionObject' object in collection.
      Console::WriteLine( "'IsHandled' status for {0} object is {1}.", myFormatExtensionObject, myCollection->IsHandled( myFormatExtensionObject ) );

      // Check 'IsRequired' status for 'myFormatExtensionObject' object in collection.
      Console::WriteLine( "'IsRequired' status for {0} object is {1}.", myFormatExtensionObject, myCollection->IsRequired( myFormatExtensionObject ) );

      // Copy elements of collection to an Object array.
      array<Object^>^myObjectArray2 = gcnew array<Object^>(myCollection->Count);
      myCollection->CopyTo( myObjectArray2, 0 );
      Console::WriteLine( "Collection elements are copied to an object array." );

      // Check for 'myFormatExtension' object in collection.
      if ( myCollection->Contains( myFormatExtensionObject ) )
      {
         // Get index of a 'myFormatExtension' object in collection.
         Console::WriteLine( "Index of 'myFormatExtensionObject' is {0} in collection.", myCollection->IndexOf( myFormatExtensionObject ) );

         // Remove 'myFormatExtensionObject' element from collection.
         myCollection->Remove( myFormatExtensionObject );
         Console::WriteLine( "'myFormatExtensionObject' is removed  from collection." );
      }

      // Insert 'MyFormatExtension' object.
      myCollection->Insert( 0, myFormatExtensionObject );
      Console::WriteLine( "'myFormatExtensionObject' is inserted to collection." );
   }
   catch ( Exception^ e ) 
   {
      Console::WriteLine( "The following exception was raised: {0}", e->Message );
   }
}
using System;
using System.Web.Services.Description;
using System.Collections;

class MyFormatExtension : ServiceDescriptionFormatExtension
{
   public MyFormatExtension()
   {
      // Set the properties.
      this.Handled  = true;
      this.Required = true;
   }
}
class myCollectionSample
{
   static void Main()
   {
      try
      {
         ServiceDescription myServiceDescription =
            ServiceDescription.Read("Sample_CS.wsdl");
         ServiceDescriptionFormatExtensionCollection  myCollection =
            new ServiceDescriptionFormatExtensionCollection(myServiceDescription);
         SoapBinding mySoapBinding1 = new SoapBinding();
         SoapBinding mySoapBinding2 = new SoapBinding();
         SoapAddressBinding mySoapAddressBinding = new SoapAddressBinding();
         MyFormatExtension  myFormatExtensionObject = new MyFormatExtension();
         // Add elements to collection.
         myCollection.Add(mySoapBinding1);
         myCollection.Add(mySoapAddressBinding);
         myCollection.Add(mySoapBinding2);
         myCollection.Add(myFormatExtensionObject);
         Console.WriteLine("Collection contains following types of elements: ");
         // Display the 'Type' of the elements in collection.
         for(int i = 0;i< myCollection.Count;i++)
         {
            Console.WriteLine(myCollection[i].GetType().ToString());
         }
         // Check element of type 'SoapAddressBinding' in collection.
         Object   myObj = myCollection.Find(mySoapAddressBinding.GetType());
         if(myObj == null)
         {
            Console.WriteLine("Element of type '{0}' not found in collection.",
               mySoapAddressBinding.GetType().ToString());
         }
         else
         {
            Console.WriteLine("Element of type '{0}' found in collection.",
               mySoapAddressBinding.GetType().ToString());
         }
         // Check all elements of type 'SoapBinding' in collection.
         Object[] myObjectArray1 = new Object[myCollection.Count];
         myObjectArray1 = myCollection.FindAll(mySoapBinding1.GetType());
         int myNumberOfElements = 0;
         IEnumerator myIEnumerator  = myObjectArray1.GetEnumerator();

         // Calculate number of elements of type 'SoapBinding'.
         while(myIEnumerator.MoveNext())
         {
            if(mySoapBinding1.GetType() == myIEnumerator.Current.GetType())
               myNumberOfElements++;
         }
         Console.WriteLine("Collection contains {0} objects of type '{1}'.",
                           myNumberOfElements.ToString(),
                           mySoapBinding1.GetType().ToString());
         // Check 'IsHandled' status for 'myFormatExtensionObject' object in collection.
         Console.WriteLine("'IsHandled' status for {0} object is {1}.",
                  myFormatExtensionObject.ToString(),
                  myCollection.IsHandled(myFormatExtensionObject).ToString());
         // Check 'IsRequired' status for 'myFormatExtensionObject' object in collection.
         Console.WriteLine("'IsRequired' status for {0} object is {1}.",
                  myFormatExtensionObject.ToString(),
                  myCollection.IsRequired(myFormatExtensionObject).ToString());
         // Copy elements of collection to an Object array.
         Object[] myObjectArray2 = new Object[myCollection.Count];
         myCollection.CopyTo(myObjectArray2,0);
         Console.WriteLine("Collection elements are copied to an object array.");
         // Check for 'myFormatExtension' object in collection.
         if(myCollection.Contains(myFormatExtensionObject))
         {
            // Get index of a 'myFormatExtension' object in collection.
            Console.WriteLine("Index of 'myFormatExtensionObject' is "+
               "{0} in collection.",
               myCollection.IndexOf(myFormatExtensionObject).ToString());
            // Remove 'myFormatExtensionObject' element from collection.
            myCollection.Remove(myFormatExtensionObject);
            Console.WriteLine("'myFormatExtensionObject' is removed"+
                              " from collection.");
         }
         // Insert 'MyFormatExtension' object.
         myCollection.Insert(0,myFormatExtensionObject);
         Console.WriteLine("'myFormatExtensionObject' is inserted to collection.");
      }
      catch(Exception e)
      {
         Console.WriteLine("The following exception was raised: {0}", e.Message);
      }
   }
}
Imports System.Web.Services.Description
Imports System.Collections


Class MyFormatExtension
   Inherits ServiceDescriptionFormatExtension
   
   Public Sub New()
      ' Set the properties.
      Me.Handled = True
      Me.Required = True
   End Sub
End Class

Class myCollectionSample
   
   Shared Sub Main()
      Try
         Dim myServiceDescription As ServiceDescription = _
                 ServiceDescription.Read("Sample_VB.wsdl")
         Dim myCollection As New ServiceDescriptionFormatExtensionCollection(myServiceDescription)
         Dim mySoapBinding1 As New SoapBinding()
         Dim mySoapBinding2 As New SoapBinding()
         Dim mySoapAddressBinding As New SoapAddressBinding()
         Dim myFormatExtensionObject As New MyFormatExtension()
         ' Add elements to collection.
         myCollection.Add(mySoapBinding1)
         myCollection.Add(mySoapAddressBinding)
         myCollection.Add(mySoapBinding2)
         myCollection.Add(myFormatExtensionObject)
         Console.WriteLine("Collection contains following types of elements: ")
         ' Display the 'Type' of the elements in collection.
         Dim i As Integer
         For i = 0 To myCollection.Count - 1
            Console.WriteLine(myCollection(i).GetType().ToString())
         Next i
         ' Check element of type 'SoapAddressBinding' in collection.
         Dim myObj As Object = myCollection.Find(mySoapAddressBinding.GetType())
         If myObj Is Nothing Then
            Console.WriteLine("Element of type '{0}' not found in collection.", _
                 mySoapAddressBinding.GetType().ToString())
         Else
            Console.WriteLine("Element of type '{0}' found in collection.", _
                 mySoapAddressBinding.GetType().ToString())
         End If
         ' Check all elements of type 'SoapBinding' in collection.
         Dim myObjectArray1(myCollection.Count -1 ) As Object
         myObjectArray1 = myCollection.FindAll(mySoapBinding1.GetType())
         Dim myNumberOfElements As Integer = 0
         Dim myIEnumerator As IEnumerator = myObjectArray1.GetEnumerator()
         
         ' Calculate number of elements of type 'SoapBinding'.
         While myIEnumerator.MoveNext()
            If mySoapBinding1.GetType() Is  myIEnumerator.Current.GetType() Then
               myNumberOfElements += 1
            End If
         End While
         Console.WriteLine("Collection contains {0} objects of type '{1}'.", _
                 myNumberOfElements.ToString(), mySoapBinding1.GetType().ToString())
         ' Check 'IsHandled' status for 'myFormatExtensionObject' object in collection.
         Console.WriteLine("'IsHandled' status for {0} object is {1}.", _
                 myFormatExtensionObject.ToString(), _
                 myCollection.IsHandled(myFormatExtensionObject).ToString())
         ' Check 'IsRequired' status for 'myFormatExtensionObject' object in collection.
         Console.WriteLine("'IsRequired' status for {0} object is {1}.", _
                 myFormatExtensionObject.ToString(), _
                 myCollection.IsRequired(myFormatExtensionObject).ToString())
         ' Copy elements of collection to an Object array.
         Dim myObjectArray2(myCollection.Count -1 ) As Object
         myCollection.CopyTo(myObjectArray2, 0)
         Console.WriteLine("Collection elements are copied to an object array.")
         ' Check for 'myFormatExtension' object in collection.
         If myCollection.Contains(myFormatExtensionObject) Then
            ' Get index of a 'myFormatExtension' object in collection.
            Console.WriteLine("Index of 'myFormatExtensionObject' is " + _
                 "{0} in collection.", myCollection.IndexOf(myFormatExtensionObject).ToString())
            ' Remove 'myFormatExtensionObject' element from collection.
            myCollection.Remove(myFormatExtensionObject)
            Console.WriteLine("'myFormatExtensionObject' is removed" + _
                 " from collection.")
         End If
         ' Insert 'MyFormatExtension' object.
         myCollection.Insert(0, myFormatExtensionObject)
         Console.WriteLine("'myFormatExtensionObject' is inserted to collection.")
      Catch e As Exception
         Console.WriteLine("The following exception was raised: {0}", e.Message.ToString())
      End Try
   End Sub
End Class

備註

這個集合可以包含衍生自 ServiceDescriptionFormatExtension 的類別實例或 類別的 XmlElement 實例。 在衍生類別中,除了 Web 服務描述語言 (WSDL) 規格中所定義的擴充性元素之外, ServiceDescriptionFormatExtension 類別還允許使用者定義擴充性元素。 如果您事先知道您想要建立的擴充性元素類型,請使用這些 ServiceDescriptionFormatExtensionCollection 專案。 XmlElement當您事先不知道元素的格式時,請使用 。

建構函式

ServiceDescriptionFormatExtensionCollection(Object)

初始化 ServiceDescriptionFormatExtensionCollection 類別的新執行個體。

屬性

Capacity

取得或設定 CollectionBase 可包含的項目數目。

(繼承來源 CollectionBase)
Count

取得 CollectionBase 執行個體中包含的元素數目。 這個屬性無法覆寫。

(繼承來源 CollectionBase)
InnerList

取得包含 ArrayList 執行個體中之元素清單的 CollectionBase

(繼承來源 CollectionBase)
Item[Int32]

取得或設定 ServiceDescriptionFormatExtensionCollection 之成員的數值。

List

取得包含 IList 執行個體中之元素清單的 CollectionBase

(繼承來源 CollectionBase)
Table

取得實作 ServiceDescriptionBaseCollection 中索引鍵和數值關聯的介面。

(繼承來源 ServiceDescriptionBaseCollection)

方法

Add(Object)

將指定的 ServiceDescriptionFormatExtension 加入至 ServiceDescriptionFormatExtensionCollection 的結尾。

Clear()

CollectionBase 執行個體移除所有的物件。 無法覆寫這個方法。

(繼承來源 CollectionBase)
Contains(Object)

傳回值,指出指定的 ServiceDescriptionFormatExtension 是否為 ServiceDescriptionFormatExtensionCollection 的成員。

CopyTo(Object[], Int32)

複製整個 ServiceDescriptionFormatExtensionCollectionServiceDescriptionFormatExtension 型別的一維陣列,從目標陣列的指定以零起始的索引位置開始。

Equals(Object)

判斷指定的物件是否等於目前的物件。

(繼承來源 Object)
Find(String, String)

ServiceDescriptionFormatExtensionCollection 中搜尋有指定名稱和命名空間 URI 的成員。

Find(Type)

搜尋 ServiceDescriptionFormatExtensionCollection,並傳回指定的衍生 Type 的第一個項目。

FindAll(String, String)

搜尋 ServiceDescriptionFormatExtensionCollection,並傳回具有指定名稱和命名空間 URI 的所有成員的陣列。

FindAll(Type)

搜尋 ServiceDescriptionFormatExtensionCollection,並傳回指定的 Type 的所有元素的陣列。

GetEnumerator()

傳回可逐一查看 CollectionBase 執行個體的列舉值。

(繼承來源 CollectionBase)
GetHashCode()

做為預設雜湊函式。

(繼承來源 Object)
GetKey(Object)

傳回與以傳址 (By Reference) 方式傳遞的數值相關聯的索引鍵名稱。

(繼承來源 ServiceDescriptionBaseCollection)
GetType()

取得目前執行個體的 Type

(繼承來源 Object)
IndexOf(Object)

搜尋指定的 ServiceDescriptionFormatExtension,並傳回集合中第一個執行個體之以零起始的索引。

Insert(Int32, Object)

加入指定的 ServiceDescriptionFormatExtensionServiceDescriptionFormatExtensionCollection,於指定的以零起始的索引位置。

IsHandled(Object)

傳回值,指出指定物件在擴充性項目匯入 XML Web Service 時是否由匯入處理序來使用。

IsRequired(Object)

傳回值,指出指定的物件對 XML Web Service 的作業是否為必須的。

MemberwiseClone()

建立目前 Object 的淺層複製。

(繼承來源 Object)
OnClear()

清除 ServiceDescriptionBaseCollection 執行個體的內容。

(繼承來源 ServiceDescriptionBaseCollection)
OnClearComplete()

在清除 CollectionBase 執行個體的內容後,執行額外的自訂處理序。

(繼承來源 CollectionBase)
OnInsert(Int32, Object)

在將新的元素插入至 CollectionBase 執行個體前,執行額外的自訂處理序。

(繼承來源 CollectionBase)
OnInsertComplete(Int32, Object)

當插入新的項目至 ServiceDescriptionBaseCollection 時,執行額外的自訂處理。

(繼承來源 ServiceDescriptionBaseCollection)
OnRemove(Int32, Object)

ServiceDescriptionBaseCollection 移除項目。

(繼承來源 ServiceDescriptionBaseCollection)
OnRemoveComplete(Int32, Object)

在從 CollectionBase 執行個體移除元素後,執行額外的自訂處理序。

(繼承來源 CollectionBase)
OnSet(Int32, Object, Object)

ServiceDescriptionBaseCollection 內以一個值取代另一個值。

(繼承來源 ServiceDescriptionBaseCollection)
OnSetComplete(Int32, Object, Object)

CollectionBase 執行個體中設定數值後,執行額外的自訂處理序。

(繼承來源 CollectionBase)
OnValidate(Object)

當驗證數值時,執行額外的自訂處理序。

(繼承來源 CollectionBase)
Remove(Object)

ServiceDescriptionFormatExtension 中移除指定 ServiceDescriptionFormatExtensionCollection 的第一個符合項目。

RemoveAt(Int32)

移除 CollectionBase 執行個體之指定索引的元素。 這個方法不可覆寫。

(繼承來源 CollectionBase)
SetParent(Object, Object)

設定 ServiceDescriptionBaseCollection 執行個體的父代 (Parent) 物件。

(繼承來源 ServiceDescriptionBaseCollection)
ToString()

傳回代表目前物件的字串。

(繼承來源 Object)

明確介面實作

ICollection.CopyTo(Array, Int32)

從目標陣列的指定索引開始,將整個 CollectionBase 複製到相容的一維 Array

(繼承來源 CollectionBase)
ICollection.IsSynchronized

取得值,這個值表示對 CollectionBase 的存取是否同步 (安全執行緒)。

(繼承來源 CollectionBase)
ICollection.SyncRoot

取得可用以同步存取 CollectionBase 的物件。

(繼承來源 CollectionBase)
IList.Add(Object)

將物件加入至 CollectionBase 的末端。

(繼承來源 CollectionBase)
IList.Contains(Object)

判斷 CollectionBase 是否包含特定項目。

(繼承來源 CollectionBase)
IList.IndexOf(Object)

搜尋指定的 Object,並傳回在整個 CollectionBase 中第一個符合項目之以零為起始的索引。

(繼承來源 CollectionBase)
IList.Insert(Int32, Object)

將項目插入至 CollectionBase 中指定的索引位置。

(繼承來源 CollectionBase)
IList.IsFixedSize

取得值,指出 CollectionBase 是否有固定的大小。

(繼承來源 CollectionBase)
IList.IsReadOnly

取得值,指出 CollectionBase 是否唯讀。

(繼承來源 CollectionBase)
IList.Item[Int32]

在指定的索引位置上取得或設定項目。

(繼承來源 CollectionBase)
IList.Remove(Object)

CollectionBase 移除特定物件之第一個符合的元素。

(繼承來源 CollectionBase)

擴充方法

Cast<TResult>(IEnumerable)

IEnumerable 的項目轉換成指定的型別。

OfType<TResult>(IEnumerable)

根據指定的型別來篩選 IEnumerable 的項目。

AsParallel(IEnumerable)

啟用查詢的平行化作業。

AsQueryable(IEnumerable)

IEnumerable 轉換成 IQueryable

適用於