public IDictionary ConvertToDictionary(object obj, Func <object, object> valueConverter) { DynamicObj dynamicObj = obj as DynamicObj; IDictionary dictionary = new Dictionary <string, object>(); string[] keys = dynamicObj.Keys; foreach (string text in keys) { dictionary.Add(text, valueConverter(dynamicObj.GetValue(text))); } return(dictionary); }