public static ActionResult AddRouteValues(this ActionResult result, RouteValueDictionary routeValues) { RouteValueDictionary currentRouteValues = result.GetRouteValueDictionary(); // Add all the extra values foreach (var pair in routeValues) { ModelUnbinderHelpers.AddRouteValues(currentRouteValues, pair.Key, pair.Value); } return(result); }
public virtual void UnbindModel(RouteValueDictionary routeValueDictionary, string routeName, object routeValue) { var dict = new RouteValueDictionary(routeValue); foreach (var entry in dict) { var name = entry.Key; if (!(entry.Value is string) && (entry.Value is System.Collections.IEnumerable)) { var enumerableValue = (System.Collections.IEnumerable)entry.Value; var i = 0; foreach (var enumerableElement in enumerableValue) { ModelUnbinderHelpers.AddRouteValues(routeValueDictionary, string.Format("{0}.{1}[{2}]", routeName, name, i), enumerableElement); i++; } } else { ModelUnbinderHelpers.AddRouteValues(routeValueDictionary, routeName + "." + name, entry.Value); } } }