mercredi 18 mai 2016

passing generic list of reflected type to method in reflected type

I'm using a third party assembly at Runtime. The assembly exposes a single method accepting a generic list of a struct. The struct is defined within the third party assembly itself.

<thirdpartassembly>
public struct stStruct
{
 public string member1;
 public decimal member2;
}
public class businessType
{
public string processItems(List<stStruct> processItems)
{
 //process items, then return result
}
}
</thirdpartassembly>

Given an instance of [businessType] created at runtime using reflection, I am trying to pass a list of items [listofStructItems] to the [processItems] method.

How do I define/create [listofStructItems] ?

What I tried so far:

  1. Passing a List containing stStruct items.
  2. Creating a struct that has the same definition as stStruct (cstStruct) in my code, then passing a List to the processItems method. (cannot convert list of x to list of y).

Environment:

  • third party assembly: .Net v.2
  • my assembly: anything above v.2

Any thoughts ? I would also appreciate an explanation of why none of the options above did work.





Aucun commentaire:

Enregistrer un commentaire