protected static TModel Create <TModel>(PythonDictionary pythonDictionary) where TModel : class, new() { if (pythonDictionary == null) { return(null); } var model = Activator.CreateInstance <TModel>(); var properties = typeof(TModel).GetProperties(BindingFlags.Public | BindingFlags.Instance); foreach (var property in properties) { var key = PythonConvert.PythonfyPropertyName(property.Name); if (!pythonDictionary.TryGetValue(key, out var value)) { continue; } value = Convert.ChangeType(value, property.PropertyType); property.SetValue(model, value); } return(model); }