CollectionAdapters.ToIListContract Méthode

Définition

Surcharges

Nom Description
ToIListContract<T>(IList<T>)

Convertit une collection spécifiée IList<T> en collection IListContract<T> .

ToIListContract<TView,TContract>(IList<TView>, Converter<TView,TContract>, Converter<TContract,TView>)

Convertit une collection spécifiée IList<T> en collection à IListContract<T> l’aide d’adaptateurs de convertisseur.

ToIListContract<T>(IList<T>)

Convertit une collection spécifiée IList<T> en collection IListContract<T> .

public:
generic <typename T>
 static System::AddIn::Contract::IListContract<T> ^ ToIListContract(System::Collections::Generic::IList<T> ^ collection);
public static System.AddIn.Contract.IListContract<T> ToIListContract<T>(System.Collections.Generic.IList<T> collection);
static member ToIListContract : System.Collections.Generic.IList<'T> -> System.AddIn.Contract.IListContract<'T>
Public Shared Function ToIListContract(Of T) (collection As IList(Of T)) As IListContract(Of T)

Paramètres de type

T

Type d’objets contenus dans la liste. T doit être sérialisable.

Paramètres

collection
IList<T>

Collection à convertir.

Retours

Collection convertie.

Exemples

L’exemple suivant implémente la classe qui définit un segment de pipeline d’adaptateur côté complément. Il adapte la méthode personnalisée ProcessBooks en prenant la IList<T> collection transmise à partir du segment de vue de complément et en la convertissant en collection IListContract<T> pouvant être marshalée sur la limite d’isolation vers l’hôte.

public override void ProcessBooks(IList<LibraryContractsHAV.BookInfo> books) {
    _contract.ProcessBooks(CollectionAdapters.ToIListContract<LibraryContractsHAV.BookInfo,
        Library.IBookInfoContract>(books,
        LibraryContractsHostAdapters.BookInfoHostAdapter.ViewToContractAdapter,
        LibraryContractsHostAdapters.BookInfoHostAdapter.ContractToViewAdapter));
}
Public Overrides Sub ProcessBooks(ByVal books As IList(Of LibraryContractsHAV.BookInfo))
    _contract.ProcessBooks(CollectionAdapters.ToIListContract(Of LibraryContractsHAV.BookInfo, _
    Library.IBookInfoContract)(books, _
    AddressOf LibraryContractsHostAdapters.BookInfoHostAdapter.ViewToContractAdapter, _
    AddressOf LibraryContractsHostAdapters.BookInfoHostAdapter.ContractToViewAdapter))
End Sub

Remarques

La IListContract<T> collection peut être marshalée sur la limite d’isolation entre le complément et son application hôte.

Vous devez utiliser cette surcharge de méthode uniquement lorsque le contenu de la IList<T> collection est des types sérialisables qui peuvent être transmis directement au contrat (plutôt que les types qui doivent être adaptés aux contrats).

S’applique à

ToIListContract<TView,TContract>(IList<TView>, Converter<TView,TContract>, Converter<TContract,TView>)

Convertit une collection spécifiée IList<T> en collection à IListContract<T> l’aide d’adaptateurs de convertisseur.

public:
generic <typename TView, typename TContract>
 static System::AddIn::Contract::IListContract<TContract> ^ ToIListContract(System::Collections::Generic::IList<TView> ^ collection, Converter<TView, TContract> ^ viewContractAdapter, Converter<TContract, TView> ^ contractViewAdapter);
public static System.AddIn.Contract.IListContract<TContract> ToIListContract<TView,TContract>(System.Collections.Generic.IList<TView> collection, Converter<TView,TContract> viewContractAdapter, Converter<TContract,TView> contractViewAdapter);
static member ToIListContract : System.Collections.Generic.IList<'View> * Converter<'View, 'Contract> * Converter<'Contract, 'View> -> System.AddIn.Contract.IListContract<'Contract>
Public Shared Function ToIListContract(Of TView, TContract) (collection As IList(Of TView), viewContractAdapter As Converter(Of TView, TContract), contractViewAdapter As Converter(Of TContract, TView)) As IListContract(Of TContract)

Paramètres de type

TView

Type qui définit l’affichage des objets de la liste.

TContract

Type qui définit le contrat pour passer des objets de type TView au-delà de la limite d’isolation.

Paramètres

collection
IList<TView>

Collection à convertir.

viewContractAdapter
Converter<TView,TContract>

Convertisseur qui adapte les données du type défini dans la vue au type attendu par le contrat.

contractViewAdapter
Converter<TContract,TView>

Convertisseur qui adapte les données du type défini dans le contrat au type attendu dans la vue.

Retours

IListContract<TContract>

Collection convertie.

Remarques

Utilisez cette surcharge de méthode pour IList<T> les collections qui contiennent des types qui doivent être adaptés aux contrats avant de pouvoir être passés au contrat (plutôt que de simples types sérialisables qui peuvent être passés directement). La IListContract<T> collection peut être marshalée sur la limite d’isolation entre un complément et son application hôte.

S’applique à