Ok, so basically I need to create a generic method which takes a list of frontend objects, retrieves the wrapped data object of each frontend object and returns a list of data objects.
I have written this method inside a singleton class.
public IEnumerable<T> GetDataItemsFromFrontend<T>(IEnumerable<T> frontendItems)
{
List<T> dataItems = new List<T>();
foreach(T frontendItem in frontendItems)
{
dataItems.Add(T.GetDataItem());
}
return dataItems;
}
Quite naturally, T.GetUser() does not exist. To give you a better idea of what I intend to do:
I have an entity object called User (generated by the Entity-Model Framework). To add functionality to User, I created a wrapper object called ClassFrontend where class is replaced by the entity title in question (for example, UserFrontend, RoleFrontend, etc).
I called the entity object inside the frontend class Data.
Now I would like to have a Generic method, which I give it a list of frontend items, and it gives me back a list of entity objects – naturally the list would be all of the same type: example all of UserFrontend, or all of RoleFrontend, etc.
Thanks.
I would make the FrontEnd objects implement an interface like below: