共用方式為


JavaScriptConverter.SupportedTypes 屬性

定義

在衍生類別中覆寫時,取得所支援型別的集合。

public:
 abstract property System::Collections::Generic::IEnumerable<Type ^> ^ SupportedTypes { System::Collections::Generic::IEnumerable<Type ^> ^ get(); };
public abstract System.Collections.Generic.IEnumerable<Type> SupportedTypes { get; }
member this.SupportedTypes : seq<Type>
Public MustOverride ReadOnly Property SupportedTypes As IEnumerable(Of Type)

屬性值

實作 IEnumerable<T> 的物件,表示轉換子支援的型別。

範例

下列範例示範如何覆寫 SupportedTypes 衍生類別中的 屬性。 在此範例中,轉換器只 ListItemCollection 支援 類型。 此程式碼範例是提供給 類別之較大範例的 JavaScriptConverter 一部分。

public override IEnumerable<Type> SupportedTypes
{
    //Define the ListItemCollection as a supported type.
    get { return new ReadOnlyCollection<Type>(new List<Type>(new Type[] { typeof(ListItemCollection) })); }
}
Public Overrides ReadOnly Property SupportedTypes() As _
    System.Collections.Generic.IEnumerable(Of System.Type)
    Get
        ' Define the ListItemCollection as a supported type.
        Return New ReadOnlyCollection(Of Type)(New List(Of Type) _
        (New Type() {GetType(ListItemCollection)}))
    End Get
End Property

備註

屬性 SupportedTypes 會列出轉換器所支援的類型。 在執行時間, JavaScriptSerializer 實例會使用這個屬性來判斷 Managed 型別與其對應自訂轉換器的對應。

給實施者的注意事項

SupportedTypes 必須一律傳回集合,而且集合必須至少包含一個專案。

適用於