-
-
Notifications
You must be signed in to change notification settings - Fork 201
[Feature] Remove ASP.NET Core dependency from TickerQ.Utilities to support all .NET platforms #480
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| using Microsoft.AspNetCore.Builder; | ||
| using TickerQ.Utilities.Enums; | ||
| using System; | ||
| using Microsoft.Extensions.DependencyInjection; | ||
| using TickerQ.DependencyInjection; | ||
| using TickerQ.Utilities; | ||
|
|
||
| namespace TickerQ.Dashboard.DependencyInjection | ||
| { | ||
| /// <summary> | ||
| /// ASP.NET Core specific extensions for TickerQ with Dashboard support | ||
| /// </summary> | ||
| public static class AspNetCoreExtensions | ||
| { | ||
| /// <summary> | ||
| /// Initializes TickerQ for ASP.NET Core applications with Dashboard support | ||
| /// </summary> | ||
| public static IApplicationBuilder UseTickerQ(this IApplicationBuilder app, TickerQStartMode qStartMode = TickerQStartMode.Immediate) | ||
| { | ||
| var serviceProvider = app.ApplicationServices; | ||
|
|
||
| // Initialize core TickerQ functionality using the base extension from TickerQ package | ||
| serviceProvider.UseTickerQ(qStartMode); | ||
|
|
||
| // Handle Dashboard-specific initialization if configured | ||
| var tickerExecutionContext = serviceProvider.GetService<TickerExecutionContext>(); | ||
| if (tickerExecutionContext?.DashboardApplicationAction != null) | ||
| { | ||
| // Cast object back to IApplicationBuilder for Dashboard middleware | ||
| tickerExecutionContext.DashboardApplicationAction(app); | ||
| tickerExecutionContext.DashboardApplicationAction = null; | ||
| } | ||
|
|
||
| return app; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,7 @@ | ||
| using System; | ||
| using System.Runtime.InteropServices; | ||
| using System.Threading; | ||
| using Microsoft.AspNetCore.Builder; | ||
| using Microsoft.Extensions.Hosting; | ||
| using TickerQ.Utilities.Enums; | ||
| using TickerQ.Utilities.Models; | ||
|
|
||
|
|
@@ -18,7 +18,7 @@ internal class TickerExecutionContext | |
| { | ||
| private long _nextOccurrenceTicks; | ||
| internal Action<IServiceProvider> ExternalProviderApplicationAction { get; set; } | ||
| internal Action<IApplicationBuilder> DashboardApplicationAction { get; set; } | ||
| internal Action<object> DashboardApplicationAction { get; set; } | ||
|
||
| public Action<object, CoreNotifyActionType> NotifyCoreAction { get; set; } | ||
| public string LastHostExceptionMessage { get; set; } | ||
| internal ITickerOptionsSeeding OptionsSeeding { get; set; } | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,7 +1,7 @@ | ||||||||||||||||||||||||||||||||||||||||||||||
| using System; | ||||||||||||||||||||||||||||||||||||||||||||||
| using System.Text.Json; | ||||||||||||||||||||||||||||||||||||||||||||||
| using Microsoft.AspNetCore.Builder; | ||||||||||||||||||||||||||||||||||||||||||||||
| using Microsoft.Extensions.DependencyInjection; | ||||||||||||||||||||||||||||||||||||||||||||||
| using Microsoft.Extensions.Hosting; | ||||||||||||||||||||||||||||||||||||||||||||||
| using TickerQ.Utilities.Entities; | ||||||||||||||||||||||||||||||||||||||||||||||
| using TickerQ.Utilities.Interfaces; | ||||||||||||||||||||||||||||||||||||||||||||||
| using TickerQ.Utilities.Interfaces.Managers; | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -171,7 +171,7 @@ public TickerOptionsBuilder<TTimeTicker, TCronTicker> SetExceptionHandler<THandl | |||||||||||||||||||||||||||||||||||||||||||||
| internal void UseExternalProviderApplication(Action<IServiceProvider> action) | ||||||||||||||||||||||||||||||||||||||||||||||
| => _tickerExecutionContext.ExternalProviderApplicationAction = action; | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| internal void UseDashboardApplication(Action<IApplicationBuilder> action) | ||||||||||||||||||||||||||||||||||||||||||||||
| internal void UseDashboardApplication(Action<object> action) | ||||||||||||||||||||||||||||||||||||||||||||||
| => _tickerExecutionContext.DashboardApplicationAction = action; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+174
to
175
|
||||||||||||||||||||||||||||||||||||||||||||||
| internal void UseDashboardApplication(Action<object> action) | |
| => _tickerExecutionContext.DashboardApplicationAction = action; | |
| internal void UseDashboardApplication<TDashboardBuilder>(Action<TDashboardBuilder> action) | |
| where TDashboardBuilder : class | |
| { | |
| if (action == null) throw new ArgumentNullException(nameof(action)); | |
| _tickerExecutionContext.DashboardApplicationAction = builderObj => | |
| { | |
| if (builderObj is TDashboardBuilder typedBuilder) | |
| { | |
| action(typedBuilder); | |
| } | |
| else | |
| { | |
| throw new InvalidOperationException( | |
| $"Dashboard application builder type mismatch. " + | |
| $"Expected '{typeof(TDashboardBuilder).FullName}', " + | |
| $"but received '{builderObj?.GetType().FullName ?? "null"}'."); | |
| } | |
| }; | |
| } |
Uh oh!
There was an error while loading. Please reload this page.