You can do something like these and cast them to a known interface.
var someVar = Convert.ChangeType(someOriginalValue, workItem[LeftFieldName].GetType());
var someVar = Activator.CreateInstance(workItem[LeftFieldName].GetType());
If you replace var
with dynamic
(and you are using .Net 4), you can call the methods you expect on the someVar object. If they don't exist, you'll just get a MissingMethodException.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…