CollectionAdapters.cs source code in C# .NET

Source code for the .NET framework in C#

                        

Code:

/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / AddIn / AddIn / System / Addin / Pipeline / CollectionAdapters.cs / 1305376 / CollectionAdapters.cs

                            // ==++== 
//
//   Copyright (c) Microsoft Corporation.  All rights reserved.
//
// ==--== 
/*============================================================
** 
** Class:  CollectionAdapters 
**
** Purpose: Provides methods to convert from IList to IListContract 
** and vice versa.
**
===========================================================*/
using System; 
using System.Collections.Generic;
using System.AddIn.Contract; 
using System.AddIn; 

namespace System.AddIn.Pipeline 
{
    public static class CollectionAdapters
    {
        // Create a IListContract wrapper for an IList.  This is typically done 
        // by an addin adapter that wants to pass a list of objects to the host,
        // or vice versa. 
        public static IListContract ToIListContract( 
            IList collection,
            Converter viewContractAdapter, 
            Converter contractViewAdapter)
        {
            if (collection == null)
                return null; 
            return new ListContractAdapter(collection, viewContractAdapter, contractViewAdapter);
        } 
 
        public static IListContract ToIListContract(IList collection)
        { 
            if (collection == null)
                return null;
            Converter c = new Converter(IdentityConverter);
            return ToIListContract(collection, c, c); 
        }
 
        // Create an IList that wraps a IContractList.  The returned IList will 
        // have a lifetimeToken for the remote IContractList.  Its finalizer
        // will revoke the lifetimeToken. 
        public static IList ToIList(
            IListContract collection,
            Converter contractViewAdapter,
            Converter viewContractAdapter) 
        {
            if (collection == null) 
                return null; 
            return new ContractListAdapter(collection, contractViewAdapter, viewContractAdapter);
        } 

        public static IList ToIList(IListContract collection)
        {
            if (collection == null) 
                return null;
            Converter c = new Converter(IdentityConverter); 
            return ToIList(collection, c, c); 
        }
 
        private static T IdentityConverter(T item)
        {
            return item;
        } 
    }
} 
 

// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// ==++== 
//
//   Copyright (c) Microsoft Corporation.  All rights reserved.
//
// ==--== 
/*============================================================
** 
** Class:  CollectionAdapters 
**
** Purpose: Provides methods to convert from IList to IListContract 
** and vice versa.
**
===========================================================*/
using System; 
using System.Collections.Generic;
using System.AddIn.Contract; 
using System.AddIn; 

namespace System.AddIn.Pipeline 
{
    public static class CollectionAdapters
    {
        // Create a IListContract wrapper for an IList.  This is typically done 
        // by an addin adapter that wants to pass a list of objects to the host,
        // or vice versa. 
        public static IListContract ToIListContract( 
            IList collection,
            Converter viewContractAdapter, 
            Converter contractViewAdapter)
        {
            if (collection == null)
                return null; 
            return new ListContractAdapter(collection, viewContractAdapter, contractViewAdapter);
        } 
 
        public static IListContract ToIListContract(IList collection)
        { 
            if (collection == null)
                return null;
            Converter c = new Converter(IdentityConverter);
            return ToIListContract(collection, c, c); 
        }
 
        // Create an IList that wraps a IContractList.  The returned IList will 
        // have a lifetimeToken for the remote IContractList.  Its finalizer
        // will revoke the lifetimeToken. 
        public static IList ToIList(
            IListContract collection,
            Converter contractViewAdapter,
            Converter viewContractAdapter) 
        {
            if (collection == null) 
                return null; 
            return new ContractListAdapter(collection, contractViewAdapter, viewContractAdapter);
        } 

        public static IList ToIList(IListContract collection)
        {
            if (collection == null) 
                return null;
            Converter c = new Converter(IdentityConverter); 
            return ToIList(collection, c, c); 
        }
 
        private static T IdentityConverter(T item)
        {
            return item;
        } 
    }
} 
 

// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
                        

Link Menu

Network programming in C#, Network Programming in VB.NET, Network Programming in .NET
This book is available now!
Buy at Amazon US or
Buy at Amazon UK