Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save seangwright/4b0b3d1f4e7670194c8d76c427d83bcb to your computer and use it in GitHub Desktop.
Save seangwright/4b0b3d1f4e7670194c8d76c427d83bcb to your computer and use it in GitHub Desktop.
/// DependencyConfiguration.cs
/// --------------------------
// ContainerBuilder builder from Autofac
builder.RegisterAssemblyTypes(assemblies)
.Where(t => t.IsClass && !t.IsAbstract && t.Name.EndsWith("RouteRegistry"))
.AsImplementedInterfaces();
/// RouteConfig.cs
/// --------------
public class RouteConfig
{
public static void RegisterRoutes(RouteCollection routes, IContainer container)
{
var routeRegistries = container
.Resolve<IEnumerable<IRouteRegistry>>()
.OrderBy(r => r.Priority);
foreach (var routeRegistry in routeRegistries)
{
routeRegistry.RegisterRoutes(routes);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment