I have a question, I think it is basic knowledge but can not find any source of information to fill my gap.
Situation looks like this I am deserilizing couple of objects using for each. Foe example:
foreach (var property in _foundBackupProjectFiles)
{
DeserializeDocumentSetFromBinary(property.Key);
}
Where _foundBackupProjectFiles is Dictionary Key is name of the object value is list of serilized files (names + path).
Now each object is a different list, for now I am using:
if (property == "Document")
{
var deserilized = (List<DocumentSet.Document>) bformatter.Deserialize(stream);
listdoc.AddRange(deserilized);
}
else if (property == "DocumentLookup")
{
var deserilized = (List<DocumentSet.DocumentLookup>) bformatter.Deserialize(stream);
listdoclookup.AddRange(deserilized);
}
else if (property == "DocumentText")
{
var deserilized = (List<DocumentSet.DocumentText>) bformatter.Deserialize(stream);
listdoctxt.AddRange(deserilized);
}
It works but it looks pretty ugly and hard to read, is there an elegant way to delegate this part :
var deserilized = List<DocumentSet.DocumentText>)bformatter.Deserialize(stream);
listdoctxt.AddRange(deserilized);
and add dynamic typing ?