I need to create a function that takes a List and 2 property names of T and return a list meeting the requirements of a specified interface plus any other properties of T.
Eg.
interface ITest
{
int ID {get;set};
int ParentID {get;set;};
}
Consumer has any class that is convertible into this interface but with potentially different properties than is required by the interface:
public class ConsumingClass
{
public int ConsumingClassID {get;set;
public int ConsumingClassParentID {get;set;}
public string namex {get;set;}
public string namey {get;set;}
}
So the consumer needs to get an object that meets the requirements of the interface, so he wants to call a function such as:
List<ITest> getnewlist = ConvertList<ConsumingClass>(consuminglist, "ConsumingClassID", "ConsumingClassParentID");
The signature of the method would look like this:
public List<ITest> ConvertList<T>(List<T> ListBeingConverted, string IDAlias, string ParentIDAlias)
{
//code needs to return a list meeting ITest requirements plus any other properties contained in T
}
Edit: I modified the signature to more appropriately reflect what I'm looking to return.