CollectionAdapters.ToIList<T> Method (IListContract<T>)
Converts the specified IListContract<T> collection to an IList<T> collection.
Assembly: System.AddIn (in System.AddIn.dll)
Type Parameters
- T
The type of objects that are contained in the list. T must be serializable.
Parameters
- collection
- Type: System.AddIn.Contract.IListContract<T>
The collection from the other side of the pipeline.
The host application or add-in can use the returned IList<T> collection. The IList<T> collection will have a lifetime token for the remote IListContract<T> collection.
You should use this method overload only when the contents of the IListContract<T> are serializable types that can be passed directly to the add-in and host (rather than types that must be adapted into views).
The following example implements a host-side adapter pipeline segment as described Walkthrough: Passing Collections Between Hosts and Add-Ins. The example adapts the custom ProcessBooks method by taking the IListContract<T> collection passed from the add-in and converting it to an IList<T> collection, which the host application can then use.
public virtual void ProcessBooks(IListContract<Library.IBookInfoContract> books) { _view.ProcessBooks(CollectionAdapters.ToIList<Library.IBookInfoContract, LibraryContractsBase.BookInfo>(books, LibraryContractsAddInAdapters.BookInfoAddInAdapter.ContractToViewAdapter, LibraryContractsAddInAdapters.BookInfoAddInAdapter.ViewToContractAdapter)); }
Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.