Skip to content

Commit 78ad443

Browse files
committed
Add xmldocs for the most important dashboard types
1 parent 43c5456 commit 78ad443

File tree

5 files changed

+202
-6
lines changed

5 files changed

+202
-6
lines changed

src/Hangfire.Core/Dashboard/DashboardContext.cs

Lines changed: 62 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,38 +20,94 @@
2020

2121
namespace Hangfire.Dashboard
2222
{
23+
/// <summary>
24+
/// Provides the context for the Dashboard UI. This class serves as a base class for specific web application frameworks,
25+
/// such as ASP.NET Core or OWIN, and is accessible from different Dashboard UI request dispatchers (please see
26+
/// <see cref="IDashboardDispatcher"/>), like pages or other endpoints.
27+
/// </summary>
28+
/// <remarks>
29+
/// The <see cref="DashboardContext"/> class encapsulates the HTTP request and response details,
30+
/// along with settings and services necessary to process dashboard requests.
31+
/// It provides an abstraction that allows easy integration with various web frameworks by inheriting from this class
32+
/// and implementing the specific behavior required for those frameworks.
33+
/// </remarks>
2334
public abstract class DashboardContext
2435
{
2536
private readonly Lazy<bool> _isReadOnlyLazy;
2637

38+
/// <summary>
39+
/// Initializes a new instance of the <see cref="DashboardContext"/> class.
40+
/// </summary>
41+
/// <param name="storage">The job storage used by the Dashboard UI.</param>
42+
/// <param name="options">The options for configuring the Dashboard UI.</param>
43+
/// <exception cref="ArgumentNullException">
44+
/// Thrown when <paramref name="storage"/> or <paramref name="options"/> is null.
45+
/// </exception>
2746
protected DashboardContext([NotNull] JobStorage storage, [NotNull] DashboardOptions options)
2847
{
29-
if (storage == null) throw new ArgumentNullException(nameof(storage));
30-
if (options == null) throw new ArgumentNullException(nameof(options));
48+
Storage = storage ?? throw new ArgumentNullException(nameof(storage));
49+
Options = options ?? throw new ArgumentNullException(nameof(options));
3150

32-
Storage = storage;
33-
Options = options;
34-
_isReadOnlyLazy = new Lazy<bool>(() => options.IsReadOnlyFunc(this));
51+
_isReadOnlyLazy = new Lazy<bool>(() => Options.IsReadOnlyFunc(this));
3552
}
3653

54+
/// <summary>
55+
/// Gets the <see cref="JobStorage"/> instance used by the Dashboard UI.
56+
/// </summary>
3757
public JobStorage Storage { get; }
58+
59+
/// <summary>
60+
/// Gets the <see cref="DashboardOptions"/> for configuring the Dashboard UI.
61+
/// </summary>
3862
public DashboardOptions Options { get; }
3963

64+
/// <summary>
65+
/// Gets or sets the URI match information passed from the configured <c>pathTemplate</c>
66+
/// when defining a route in the <see cref="DashboardRoutes"/> class.
67+
/// </summary>
4068
public Match UriMatch { get; set; }
41-
69+
70+
/// <summary>
71+
/// Gets the <see cref="DashboardRequest"/> metadata.
72+
/// Used by request dispatchers (please see <see cref="IDashboardDispatcher"/>) to provide request information.
73+
/// </summary>
4274
public DashboardRequest Request { get; protected set; }
75+
76+
/// <summary>
77+
/// Gets the <see cref="DashboardResponse"/> metadata.
78+
/// Used by request dispatchers (please see <see cref="IDashboardDispatcher"/>) to send response information.
79+
/// </summary>
4380
public DashboardResponse Response { get; protected set; }
4481

82+
/// <summary>
83+
/// Gets a value indicating whether the Dashboard UI is in read-only mode to possibly
84+
/// hide elements that modify the <see cref="JobStorage"/> instance's data.
85+
/// </summary>
4586
public bool IsReadOnly => _isReadOnlyLazy.Value;
4687

88+
/// <summary>
89+
/// Gets or sets the anti-forgery header value.
90+
/// </summary>
4791
public string AntiforgeryHeader { get; set; }
92+
93+
/// <summary>
94+
/// Gets or sets the anti-forgery token value.
95+
/// </summary>
4896
public string AntiforgeryToken { get; set; }
4997

98+
/// <summary>
99+
/// Gets the background job client for the current <see cref="JobStorage"/> instance.
100+
/// </summary>
101+
/// <returns>An instance of <see cref="IBackgroundJobClient"/>.</returns>
50102
public virtual IBackgroundJobClient GetBackgroundJobClient()
51103
{
52104
return new BackgroundJobClient(Storage);
53105
}
54106

107+
/// <summary>
108+
/// Gets the recurring job manager for the current <see cref="JobStorage"/> instance.
109+
/// </summary>
110+
/// <returns>An instance of <see cref="IRecurringJobManager"/>.</returns>
55111
public virtual IRecurringJobManager GetRecurringJobManager()
56112
{
57113
return new RecurringJobManager(

src/Hangfire.Core/Dashboard/DashboardRequest.cs

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,57 @@
1818

1919
namespace Hangfire.Dashboard
2020
{
21+
/// <summary>
22+
/// Provides the request details for the Dashboard UI. This class serves as an abstraction for HTTP requests
23+
/// and is used within <see cref="IDashboardDispatcher"/> implementations to access request information.
24+
/// </summary>
25+
/// <remarks>
26+
/// The <see cref="DashboardRequest"/> class encapsulates the HTTP request details, providing properties to access
27+
/// the method, path, base path, IP addresses, and query or form values.
28+
/// This allows for a consistent way to handle requests across different web frameworks.
29+
/// </remarks>
2130
public abstract class DashboardRequest
2231
{
32+
/// <summary>
33+
/// Gets the HTTP method of the request like <c>"GET"</c> or <c>"POST"</c>, that can
34+
/// be checked for equality by using the <see cref="System.StringComparison.OrdinalIgnoreCase"/> comparer.
35+
/// </summary>
2336
public abstract string Method { get; }
37+
38+
/// <summary>
39+
/// Gets the request path for the current request that doesn't include the <see cref="DashboardOptions.PrefixPath"/>,
40+
/// like <c>"/jobs/enqueued"</c>.
41+
/// </summary>
2442
public abstract string Path { get; }
43+
44+
/// <summary>
45+
/// Gets the base path for the request configured in the request middleware, usually useful
46+
/// to reconstruct full URIs like for link generation.
47+
/// </summary>
2548
public abstract string PathBase { get; }
2649

50+
/// <summary>
51+
/// Gets the local IP address from which the request originated.
52+
/// </summary>
2753
public abstract string LocalIpAddress { get; }
54+
55+
/// <summary>
56+
/// Gets the remote IP address from which the request originated.
57+
/// </summary>
2858
public abstract string RemoteIpAddress { get; }
2959

60+
/// <summary>
61+
/// Gets the value of a specific query string parameter.
62+
/// </summary>
63+
/// <param name="key">The key of the query string parameter.</param>
64+
/// <returns>The value of the query string parameter.</returns>
3065
public abstract string GetQuery(string key);
66+
67+
/// <summary>
68+
/// Gets the values of a specific form parameter asynchronously, reading the request body if it's a form.
69+
/// </summary>
70+
/// <param name="key">The key of the form parameter.</param>
71+
/// <returns>A task that represents the asynchronous operation. The task result contains the list of values for the form parameter.</returns>
3172
public abstract Task<IList<string>> GetFormValuesAsync(string key);
3273
}
3374
}

src/Hangfire.Core/Dashboard/DashboardResponse.cs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,47 @@
1919

2020
namespace Hangfire.Dashboard
2121
{
22+
/// <summary>
23+
/// Provides the response details for the Dashboard UI. This class serves as an abstraction for HTTP responses
24+
/// and is used within <see cref="IDashboardDispatcher"/> implementations to send response information.
25+
/// </summary>
26+
/// <remarks>
27+
/// The <see cref="DashboardResponse"/> class encapsulates the HTTP response details, providing properties and methods
28+
/// to set the content type, status code, body, and expiration of the response.
29+
/// This allows for a consistent way to handle responses across different web frameworks.
30+
/// </remarks>
2231
public abstract class DashboardResponse
2332
{
33+
/// <summary>
34+
/// Gets or sets the content type of the response like <c>"application/json"</c>.
35+
/// </summary>
36+
/// <value>The content type of the response.</value>
2437
public abstract string ContentType { get; set; }
38+
39+
/// <summary>
40+
/// Gets or sets the HTTP status code of the response like <c>200</c>.
41+
/// </summary>
42+
/// <value>The status code of the response.</value>
2543
public abstract int StatusCode { get; set; }
2644

45+
/// <summary>
46+
/// Gets the response body stream, most of the time it's better to use the
47+
/// <see cref="WriteAsync"/> method instead for text data.
48+
/// </summary>
49+
/// <value>The response body stream.</value>
2750
public abstract Stream Body { get; }
2851

52+
/// <summary>
53+
/// Sets the expiration time for the response.
54+
/// </summary>
55+
/// <param name="value">The expiration time, or <c>null</c> to remove the expiration header.</param>
2956
public abstract void SetExpire(DateTimeOffset? value);
57+
58+
/// <summary>
59+
/// Writes the specified text to the response body asynchronously.
60+
/// </summary>
61+
/// <param name="text">The text to write to the response body.</param>
62+
/// <returns>A task that represents the asynchronous operation.</returns>
3063
public abstract Task WriteAsync(string text);
3164
}
3265
}

src/Hangfire.Core/Dashboard/DashboardRoutes.cs

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,19 @@
2222

2323
namespace Hangfire.Dashboard
2424
{
25+
/// <summary>
26+
/// Provides the routing mechanisms for the Dashboard UI. This class is used to register custom
27+
/// request dispatchers, allowing developers to write extensions for the Dashboard UI, such as
28+
/// custom pages, API endpoints or adding custom JavaScript or CSS files.
29+
/// </summary>
30+
/// <remarks>
31+
/// The <see cref="DashboardRoutes"/> class contains a collection of routes that the Dashboard UI uses to dispatch requests to handlers.
32+
/// Developers can use this class to add custom scripts, stylesheets, and register custom routes for extending the dashboard functionality.
33+
///
34+
/// To add a custom route, use the <see cref="DashboardRoutes.Routes"/> property which is an instance of <see cref="RouteCollection"/>.
35+
/// </remarks>
36+
/// <seealso cref="RouteCollection"/>
37+
/// <seealso cref="IDashboardDispatcher"/>
2538
public static class DashboardRoutes
2639
{
2740
private static readonly List<Tuple<Assembly, string>> JavaScripts = new List<Tuple<Assembly, string>>();
@@ -179,8 +192,22 @@ static DashboardRoutes()
179192
#endregion
180193
}
181194

195+
/// <summary>
196+
/// Gets the collection of routes for the Dashboard UI. Use this property to register
197+
/// custom request dispatchers.
198+
/// </summary>
182199
public static RouteCollection Routes { get; }
183200

201+
/// <summary>
202+
/// Adds a stylesheet resource embedded into the given assembly to be included in the dashboard.
203+
/// </summary>
204+
/// <remarks>
205+
/// The specified resource should be an embedded resource file within the referenced assembly.
206+
/// You can discover embedded resource names by calling the <c>assembly.GetManifestResourceNames()</c> method.
207+
/// </remarks>
208+
/// <param name="assembly">The assembly containing the embedded stylesheet resource.</param>
209+
/// <param name="resource">The name of the stylesheet embedded resource.</param>
210+
/// <exception cref="ArgumentNullException">Thrown if <paramref name="assembly"/> or <paramref name="resource"/> is <c>null</c>.</exception>
184211
public static void AddStylesheet([NotNull] Assembly assembly, [NotNull] string resource)
185212
{
186213
if (assembly == null) throw new ArgumentNullException(nameof(assembly));
@@ -193,6 +220,17 @@ public static void AddStylesheet([NotNull] Assembly assembly, [NotNull] string r
193220
}
194221
}
195222

223+
/// <summary>
224+
/// Adds a resource embedded into the given assembly that will only be included in the dashboard
225+
/// when the <see cref="DashboardOptions.DarkModeEnabled"/> is set to <c>true</c>.
226+
/// </summary>
227+
/// <remarks>
228+
/// The specified resource should be an embedded resource file within the referenced assembly.
229+
/// You can discover embedded resource names by calling the <c>assembly.GetManifestResourceNames()</c> method.
230+
/// </remarks>
231+
/// <param name="assembly">The assembly containing the dark-mode stylesheet embedded resource.</param>
232+
/// <param name="resource">The name of the dark-mode stylesheet embedded resource.</param>
233+
/// <exception cref="ArgumentNullException">Thrown if <paramref name="assembly"/> or <paramref name="resource"/> is <c>null</c>.</exception>
196234
public static void AddStylesheetDarkMode([NotNull] Assembly assembly, [NotNull] string resource)
197235
{
198236
if (assembly == null) throw new ArgumentNullException(nameof(assembly));
@@ -205,6 +243,16 @@ public static void AddStylesheetDarkMode([NotNull] Assembly assembly, [NotNull]
205243
}
206244
}
207245

246+
/// <summary>
247+
/// Adds a JavaScript resource embedded into the given assembly to be included in the dashboard.
248+
/// </summary>
249+
/// <remarks>
250+
/// The specified resource should be an embedded resource file within the referenced assembly.
251+
/// You can discover embedded resource names by calling the <c>assembly.GetManifestResourceNames()</c> method.
252+
/// </remarks>
253+
/// <param name="assembly">The assembly containing the JavaScript embedded resource.</param>
254+
/// <param name="resource">The name of the JavaScript embedded resource.</param>
255+
/// <exception cref="ArgumentNullException">Thrown if <paramref name="assembly"/> or <paramref name="resource"/> is <c>null</c>.</exception>
208256
public static void AddJavaScript([NotNull] Assembly assembly, [NotNull] string resource)
209257
{
210258
if (assembly == null) throw new ArgumentNullException(nameof(assembly));

src/Hangfire.Core/Dashboard/IDashboardDispatcher.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,26 @@
1818

1919
namespace Hangfire.Dashboard
2020
{
21+
/// <summary>
22+
/// Defines the method for dispatching requests within the Dashboard UI.
23+
/// Implementations of this interface handle incoming requests to the dashboard and produce appropriate responses.
24+
/// </summary>
25+
/// <remarks>
26+
/// The <see cref="IDashboardDispatcher"/> interface is used to process requests in the Dashboard UI.
27+
/// Implement this interface to handle custom routes and manage request processing logic.
28+
///
29+
/// To register custom dispatchers, use the <see cref="DashboardRoutes"/> class. The <c>DashboardRoutes.Routes</c>
30+
/// property allows for adding new routes that the dashboard will use to dispatch requests to custom handlers.
31+
/// </remarks>
32+
/// <seealso cref="DashboardContext"/>
33+
/// <seealso cref="DashboardRoutes"/>
2134
public interface IDashboardDispatcher
2235
{
36+
/// <summary>
37+
/// Processes the request within the provided <see cref="DashboardContext"/>.
38+
/// </summary>
39+
/// <param name="context">The context for the current dashboard request, containing information about the request and response.</param>
40+
/// <returns>A task that represents the asynchronous dispatch operation.</returns>
2341
Task Dispatch([NotNull] DashboardContext context);
2442
}
2543
}

0 commit comments

Comments
 (0)