Export (0) Print
Expand All

CollectionAdapters.ToIListContract<T> Method (IList<T>)

Converts a specified IList<T> collection to an IListContract<T> collection.

Namespace:  System.AddIn.Pipeline
Assembly:  System.AddIn (in System.AddIn.dll)

public static IListContract<T> ToIListContract<T>(
	IList<T> collection
)

Type Parameters

T

The type of objects that are contained in the list. T must be serializable.

Parameters

collection
Type: System.Collections.Generic.IList<T>

The collection to convert.

Return Value

Type: System.AddIn.Contract.IListContract<T>
The converted collection.

The IListContract<T> collection can be marshaled across the isolation boundary between the add-in and its host application.

You should use this method overload only when the contents of the IList<T> collection are serializable types that can be passed directly to the contract (rather than types that must be adapted into contracts).

The following example implements the class that defines an add-in side adapter pipeline segment. It adapts the custom ProcessBooks method by taking the IList<T> collection passed from the add-in view segment and converting it to an IListContract<T> collection that can be marshaled across the isolation boundary to the host.

public override void ProcessBooks(IList<LibraryContractsHAV.BookInfo> books) {
    _contract.ProcessBooks(CollectionAdapters.ToIListContract<LibraryContractsHAV.BookInfo,
        Library.IBookInfoContract>(books,
        LibraryContractsHostAdapters.BookInfoHostAdapter.ViewToContractAdapter,
        LibraryContractsHostAdapters.BookInfoHostAdapter.ContractToViewAdapter));
}

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, 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.

Show:
© 2014 Microsoft