public object[] Merge(IEnumerable <ArgumentInfo> argumentInfos) { Dictionary <string, object> parameters = new Dictionary <string, object>(); foreach (var argumentInfo in argumentInfos) { if (!argumentInfo.IsPartOfModel) { parameters.Add(argumentInfo.PropertyOrArgumentName, _valueMachine.GetValue(argumentInfo)); } else { object instance; if (parameters.ContainsKey(argumentInfo.ModelType.FullName)) //already added one or more params { instance = parameters[argumentInfo.ModelType.FullName]; } else //first property of model { instance = Activator.CreateInstance(argumentInfo.ModelType); parameters.Add(argumentInfo.ModelType.FullName, instance); } PropertyInfo propertyInfo = argumentInfo.ModelType.GetProperty(argumentInfo.PropertyOrArgumentName); propertyInfo.SetValue(instance, _valueMachine.GetValue(argumentInfo)); } } return(parameters.Values.ToArray()); }
public object[] Merge(IEnumerable <ArgumentInfo> argumentInfos) { Dictionary <string, object> parameters = new Dictionary <string, object>(); foreach (var argumentInfo in argumentInfos) { if (argumentInfo.IsPartOfModel) { MergeModel(parameters, argumentInfo); } else { parameters.Add(argumentInfo.PropertyOrArgumentName, _valueMachine.GetValue(argumentInfo)); } } MergeNestedModels(parameters); // TODO: this code assumes the order of arguments will not be changed by the dictionary. // dictionaries do not guarantee order. return(parameters.Values.ToArray()); }