Skip to content

Instantly share code, notes, and snippets.

View huobazi's full-sized avatar
🎯
Focusing

Marble Wu huobazi

🎯
Focusing
View GitHub Profile
var assembly = Assembly.GetCallingAssembly();
var actionMethods = assembly.GetTypes()
// Find all non abstract classes of type Controller and whose names end with "Controller"
.Where(x => x.IsClass && !x.IsAbstract && x.IsSubclassOf(typeof(TwilioController)) && x.Name.EndsWith("Controller"))
// Find all public methods from those controller classes
.SelectMany(x => x.GetMethods().Where(m => m.DeclaringType.Name == x.Name), (x, y) => new { Controller = x.Name.Substring(0, x.Name.Length - 10), Method = y.Name });
foreach (var action in actionMethods) {
routes.MapRoute(action.Method, action.Method, new { controller = action.Controller, action = action.Method });
}
@romannurik
romannurik / background-page.html
Created September 24, 2009 05:15
A workaround for Cross-domain XHR's not working in Chrome Extensions' content scripts. See http://groups.google.com/group/chromium-extensions/browse_thread/thread/43ec4d383cf8d01d
<!DOCTYPE html>
<html>
<head>
<script src="xhrproxy.js"></script>
<script>
setupXHRProxy();
</script>
</head>