I got as far as:
T clone(T source)
{
if(source != null && source.GetType() == typeof(List<>))
{
Type listType = source.GetType();
Type listElemType = listType.GetGenericArguments()[0].GetType();
var listClone = (T)Activator.CreateInstance(listType.MakeGenericType(listElemType));
...
return listClone;
}
...
}
Now, how to fill the clone? As I said, I just need a shallow copy. Thanks.