Skip to content

Commit

Permalink
Fix compatibility with Hangfire 1.6.11+
Browse files Browse the repository at this point in the history
  • Loading branch information
pieceofsummer committed Mar 16, 2017
1 parent a6f7987 commit fe09c71
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 8 deletions.
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: 1.3.0-{build}
version: 1.3.1-{build}

os: Visual Studio 2015

Expand Down
14 changes: 9 additions & 5 deletions src/Hangfire.Console/GlobalConfigurationExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,15 @@ public static IGlobalConfiguration UseConsole(this IGlobalConfiguration configur

// register additional dispatchers for CSS and JS
var assembly = typeof(ConsoleRenderer).GetTypeInfo().Assembly;
DashboardRoutes.Routes.Append("/js[0-9]{3}", new EmbeddedResourceDispatcher(assembly, "Hangfire.Console.Resources.resize.min.js"));
DashboardRoutes.Routes.Append("/js[0-9]{3}", new DynamicJsDispatcher(options));
DashboardRoutes.Routes.Append("/js[0-9]{3}", new EmbeddedResourceDispatcher(assembly, "Hangfire.Console.Resources.script.js"));
DashboardRoutes.Routes.Append("/css[0-9]{3}", new EmbeddedResourceDispatcher(assembly, "Hangfire.Console.Resources.style.css"));
DashboardRoutes.Routes.Append("/css[0-9]{3}", new DynamicCssDispatcher(options));

var jsPath = DashboardRoutes.Routes.Contains("/js[0-9]+") ? "/js[0-9]+" : "/js[0-9]{3}";
DashboardRoutes.Routes.Append(jsPath, new EmbeddedResourceDispatcher(assembly, "Hangfire.Console.Resources.resize.min.js"));
DashboardRoutes.Routes.Append(jsPath, new DynamicJsDispatcher(options));
DashboardRoutes.Routes.Append(jsPath, new EmbeddedResourceDispatcher(assembly, "Hangfire.Console.Resources.script.js"));

var cssPath = DashboardRoutes.Routes.Contains("/css[0-9]+") ? "/css[0-9]+" : "/css[0-9]{3}";
DashboardRoutes.Routes.Append(cssPath, new EmbeddedResourceDispatcher(assembly, "Hangfire.Console.Resources.style.css"));
DashboardRoutes.Routes.Append(cssPath, new DynamicCssDispatcher(options));

return configuration;
}
Expand Down
16 changes: 16 additions & 0 deletions src/Hangfire.Console/Support/RouteCollectionExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;

namespace Hangfire.Dashboard.Extensions
Expand All @@ -23,6 +24,21 @@ private static List<Tuple<string, IDashboardDispatcher>> GetDispatchers(this Rou
return (List<Tuple<string, IDashboardDispatcher>>)_dispatchers.GetValue(routes);
}

/// <summary>
/// Checks if there's a dispatcher registered for given <paramref name="pathTemplate"/>.
/// </summary>
/// <param name="routes">Route collection</param>
/// <param name="pathTemplate">Path template</param>
public static bool Contains(this RouteCollection routes, string pathTemplate)
{
if (routes == null)
throw new ArgumentNullException(nameof(routes));
if (pathTemplate == null)
throw new ArgumentNullException(nameof(pathTemplate));

return routes.GetDispatchers().Any(x => x.Item1 == pathTemplate);
}

/// <summary>
/// Combines exising dispatcher for <paramref name="pathTemplate"/> with <paramref name="dispatcher"/>.
/// If there's no dispatcher for the specified path, adds a new one.
Expand Down
4 changes: 2 additions & 2 deletions src/Hangfire.Console/project.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "1.3.0-*",
"version": "1.3.1-*",

"title": "Hangfire.Console",
"description": "Job console for Hangfire",
Expand All @@ -11,7 +11,7 @@
"owners": [ "Alexey Skalozub" ],
"iconUrl": "https://raw.githubusercontent.com/pieceofsummer/Hangfire.Console/master/hangfire.console.png",
"licenseUrl": "https://raw.githubusercontent.com/pieceofsummer/Hangfire.Console/master/LICENSE.md",
"releaseNotes": "- Consoles are now expired along with parent job by default!\n- Added **FollowJobRetentionPolicy** option to switch between old/new expiration modes",
"releaseNotes": "- Consoles are now expired along with parent job by default!\n- Added **FollowJobRetentionPolicy** option to switch between old/new expiration modes\n- Fix compatibility with Hangfire 1.6.11+",
"repository": {
"type": "git",
"url": "https://github.com/pieceofsummer/Hangfire.Console"
Expand Down

0 comments on commit fe09c71

Please sign in to comment.