public BaseMethod MapDown(MethodMetadata model, Type methodModelType) { object methodModel = Activator.CreateInstance(methodModelType); PropertyInfo nameProperty = methodModelType.GetProperty("Name"); PropertyInfo extensionProperty = methodModelType.GetProperty("Extension"); PropertyInfo genericArgumentsProperty = methodModelType.GetProperty("GenericArguments", BindingFlags.Instance | BindingFlags.Public | BindingFlags.DeclaredOnly); PropertyInfo modifiersProperty = methodModelType.GetProperty("Modifiers"); PropertyInfo parametersProperty = methodModelType.GetProperty("Parameters", BindingFlags.Instance | BindingFlags.Public | BindingFlags.DeclaredOnly); PropertyInfo returnTypeProperty = methodModelType.GetProperty("ReturnType", BindingFlags.Instance | BindingFlags.Public | BindingFlags.DeclaredOnly); nameProperty?.SetValue(methodModel, model.Name); extensionProperty?.SetValue(methodModel, model.Extension); if (model.GenericArguments != null) { genericArgumentsProperty?.SetValue(methodModel, Helper.ConvertList(genericArgumentsProperty.PropertyType.GetGenericArguments()[0], model.GenericArguments.Select(t => TypeMapper.EmitBaseType(t, genericArgumentsProperty.PropertyType.GetGenericArguments()[0])).ToList())); } modifiersProperty?.SetValue(methodModel, model.Modifiers); if (model.Parameters != null) { parametersProperty?.SetValue(methodModel, Helper.ConvertList(parametersProperty.PropertyType.GetGenericArguments()[0], model.Parameters.Select(p => new ParameterMapper().MapDown(p, parametersProperty.PropertyType.GetGenericArguments()[0])).ToList())); } if (model.ReturnType != null) { returnTypeProperty?.SetValue(methodModel, returnTypeProperty.PropertyType.Cast(TypeMapper.EmitBaseType(model.ReturnType, returnTypeProperty.PropertyType))); } return((BaseMethod)methodModel); }