.NET Framework Bookmark and Share   
 index > .NET Base Class Library > Collections in Managed add-in framework (MAF)
 

Collections in Managed add-in framework (MAF)

Hi all,

I really hope that BCL team can provide a Best practice on this topic! Sad

I try to answer my questions in the last post and wait for your comments.

I am working with managed add-in framework now. I want to exposethe object model by MAF. But, I am lost totally.

There are some collections in existing model and these collections can drop into 3 categories:

1. normal collection (can be modified, most of them are System.Collections.Generic.List<T>);

2. readonly collection (can not ne modified, they are System.Collections.ObjectModel.ReadOnlyCollection<T>);

3. a class inherit form IEnumerable<T>.

Collections incategory 1 can be replaced byIListContract<T>, But How about category 2 and 3?

I wonder whether I can express ReadonlyCollection in MAF.

Here are my questions:

  • I found that there are two classes named IListContract<T>. One is under System.AddIn.Contract and other is under System.AddIn.Contract.Collections? What is the difference between 2 classes?
  • How to express ReadOnly collections in MAF? Here is my guess: use ReadonlyCollection<T> in View and IListContract<T>, and in adapter do following convertion (From View to Contract, e.g.):
    • i. convert ReadonlyCollection<T> to List<T>
    • ii. use System.AddIn.Pipeline.CollectionAdapters convert List<T> to IListContract<T>

But does it bring more performace issues? have somebody done it before? CollectionAdapters can only take care of IList and IListContract.

DeepNight
--What is the purpose of the class under System.AddIn.Contract.Collections?
Please check out 4. Why can’t we pass arrays of contracts? talked about this issue a little and there will be more blog posts about this in the CLR Addin Team blog.

Feng Chen

Hi all,

Let me try to simplify my question. Please forgive my poor expression.

Question 1 is:

If there are some readonly collections in my object model, how to declare them in Contract and pass them through the pipeline?

Question 2 is:

If I want declare IEnumerable<T> in my object model, is there a helper class like System.AddIn.Pipeline.CollectionAdapters to take responsiblity of convertion between view and contract? If no, does MAF can do converting between IEnumerable<T> and IEnumerableContract<T> by MAF itself?

Any comments are welcome.

BR,

DeepNight

DeepNight

I wonder whySystem.AddIn.Contract.IListContract<C> doesn't inherit form IEnumerableContract<C> like System.AddIn.Contract.Collections?

For my opion, I don't think it is necessary to put a IListContract<C> in System.AddIn.Contract. It make thing more complex and difficult to understand.

Can anyone give some reasons for it?

DeepNight

Hi all again,

I think I find the reason for my questions:

In MAF, System.AddIn.Contract.IListContract<C> is the only collection type that can be passed through the AppDomains. So I can't use System.AddIn.Contract.Collections.IListContract<T> in Contract assembly. Same to System.AddIn.Contract.IEnumertatableContract<T>.

But if I want to use IEnumerable<T> or ReadonlyCollection<T> inmy ObjectModel, IMUST do some extra works to convert IListContract<T> to IList<T> and convert the IList<T> to IEnumerable<T> or ReadonlyCollection<T>. Is it right?

If my guess is right, the only question left in my mind: What is the purpose of the class under System.AddIn.Contract.Collections?

Can somebody give me some feedback?

BR,

DeepNight

DeepNight
--What is the purpose of the class under System.AddIn.Contract.Collections?
Please check out 4. Why can’t we pass arrays of contracts? talked about this issue a little and there will be more blog posts about this in the CLR Addin Team blog.

Feng Chen

Hi Feng Chen,

Thanks for your kindly answer.

I define my object model now and met a question to define collections.

Here is a question:

Can I express IEnumerable<TContract> or ReadOnlyCollection<TContract> in contract assembly like:

public interface ICommandCollectionContract : IContract, IEnumerable<ICommandContract> {...}?

Or for ANY collections in contract assemblies should be defined like ICommandCollection : IListContract<Command> to cross app domain?

I doNOT want to make ICommandCollection to inherit from IListContract<ICommandContract> because IListContract<TContract> is too general. Sad But I find no way to define a Enumerable Collections and make it cross app domain.

BR,

DeepNight

DeepNight

Hi all,

I wonder here does IListContract<TContract> is the ONLY collection type to cross AppDomain in MAF?

I try to define a Object Model for my product, and in my Object Model there are a lot of Collections. Some of them are readonly, and others are not. And I think it is common case for defining Object Model.

But I find it seems that IListContract<TContract> is the ONLY collections typedesigned for cross AppDomain.

How can I define a IEnumerable<TContract> or ReadonlyCollection<TContract> in my Object Model Contract assembly?

Could sombody give me some instructions on it? It is hard to find resource on MSDN and internet. Sad

BR,

DeepNight

DeepNight

You can use google to search for other answers

Custom Search

More Threads

• how to solve The Undo operation encountered
• NetSVC from C#
• TIFF Image need to attach on the right side of another Tiff Image and Finally save without losing quality of image
• Print Status Info
• Explanation needed for 2 specfic PEVERIFY error messages
• Q: Executing a method in another thread
• A generic error occurred in GDI+.
• Process.Start and CREATE_NEW_CONSOLE
• Get Referenced Assemblies non used
• Reading streaming data from SerialPort