Skip to content

Instantly share code, notes, and snippets.

@hagbarddenstore
Created January 28, 2013 13:12
Show Gist options
  • Save hagbarddenstore/4655397 to your computer and use it in GitHub Desktop.
Save hagbarddenstore/4655397 to your computer and use it in GitHub Desktop.
public static AutoMappingExpression Override<TController>(this AutoMappingExpression autoMappingExpression, string url, Expression<Action<TController>> actionExpression)
{
Assert.ParameterIsNotNull(autoMappingExpression, "mappingExpression");
Assert.ParameterIsNotNull(url, "url");
var methodCallExpression = actionExpression.Body as MethodCallExpression;
if (methodCallExpression == null)
{
throw new ArgumentException("Invalid expression. Expression should consist of a Method call only.");
}
var controllerType = typeof(TController);
var actionType = methodCallExpression.Method;
return autoMappingExpression.AddOverride(controllerType, actionType, url);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment