.net - C# exposing class to COM - Generic Collections -


We have a small structure written in C # NET 2.0 that we want to expose com.

The problem is that we have some generic classes that will be highlighted as:

  Interface IOurClass {ReadonlyCollection & lt; IOurListObject & gt; Our selection {receive; }} Interface IOurListObject {// Some Properties That Make No Difference}  

What is the best (or recommended way) to expose the COM to the general collection? We do not have to support genetics, we have to highlight the collection of the Iorilist object in some way.

We also want to avoid writing a new class to use every collection, but this is not possible. It is not possible to expose the general archive (or any other thing that is 'generic') COM.

Therefore, I suggest that you make a non-general property (or method) in your COM-visible interface. This method can return an array of 'IOurListObject' items. In your class, you can apply this method clearly, so that when you reference the object directly outside of COM it does not appear in your Intelligence.

I hope I will clear myself a bit.

Example:

  [Commasible] Public Interface IOurClass {IOurListObject [] Get our selection { }} Public class OurClass: IOurClass {IOurListObject [IOurClass.OurCollection {get ourCollection.ToArray ();}} Public readline compilation & lt; IOurListObject & gt; OurCollection {...}}  

Comments

Popular posts from this blog

c# - How to capture HTTP packet with SharpPcap -

php - Multiple Select with Explode: only returns the word "Array" -

jquery - SimpleModal Confirm fails to submit form -