I have a IRecord object that can hold objects. The name of these objects is saved in mapping as Properties. I loop through the properties and get them out of the IRecord by doing
record[property]
These objects are always ICollections. However, I don't know what type the ICollection will hold before hand. How can I unbox the object to the right ICollection without knowing what the ICollection will hold?
The code below is a working version if record[property is an IColletion, so I want to change this that it can take any ICollection.
public ElectronicSignatureModel SignHierarchy(IRecord record, List<HierarchyMapping> mapping)
{
foreach (HierarchyMapping hierarchyMapping in mapping)
{
string[] propertyList = hierarchyMapping.Properties;
foreach (string property in propertyList)
{
ICollection<Sample> recordProperty = (ICollection<Sample>)record[property];
}
}