Skip to content

Commit 1bbc44b

Browse files
committed
Cleanup
1 parent b22c16c commit 1bbc44b

File tree

7 files changed

+22
-86
lines changed

7 files changed

+22
-86
lines changed

DragonFly.Proxy.Generators/DragonFly.Proxy.Generators.csproj

Lines changed: 0 additions & 15 deletions
This file was deleted.

DragonFly.Proxy.Generators/Generators/Test.cs

Lines changed: 0 additions & 41 deletions
This file was deleted.

src/DragonFly.App.Server/Program.cs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22
// https://github.com/usercode/DragonFly
33
// MIT License
44

5+
using System;
6+
using System.Threading.Tasks;
57
using DragonFly;
68
using DragonFly.AspNet.Options;
79
using DragonFly.AspNetCore;
8-
using DragonFly.Assets.Query;
910
using DragonFly.MongoDB;
1011
using ImageWizard;
1112
using ImageWizard.Caches;
@@ -56,6 +57,24 @@
5657
//init DragonFly
5758
await app.InitDragonFly();
5859

60+
//demo tasks
61+
IBackgroundTaskManager taskManager = app.Services.GetRequiredService<IBackgroundTaskManager>();
62+
taskManager.StartNew("Test", static async ctx => { await Task.Delay(TimeSpan.FromSeconds(60), ctx.CancellationToken); });
63+
taskManager.StartNew("Import", static async ctx =>
64+
{
65+
while (ctx.CancellationToken.IsCancellationRequested == false)
66+
{
67+
await Task.Delay(TimeSpan.FromSeconds(1));
68+
69+
ctx.Task.ProgressValue += 2;
70+
71+
if (ctx.Task.ProgressValue >= ctx.Task.ProgressMaxValue)
72+
{
73+
break;
74+
}
75+
}
76+
});
77+
5978
IHostEnvironment env = app.Services.GetRequiredService<IHostEnvironment>();
6079

6180
if (env.IsDevelopment())

src/DragonFly.AspNetCore/DragonFlyBuilderExtensions.cs

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -67,25 +67,7 @@ public static IDragonFlyBuilder AddDragonFly(this IServiceCollection services)
6767
public static async Task InitDragonFly(this IHost host)
6868
{
6969
IDragonFlyApi api = host.Services.GetRequiredService<IDragonFlyApi>();
70-
await api.InitAsync();
71-
72-
////demo tasks
73-
//IBackgroundTaskManager taskManager = host.Services.GetRequiredService<IBackgroundTaskManager>();
74-
//taskManager.StartNew("Test", static async ctx => { await Task.Delay(TimeSpan.FromSeconds(60), ctx.CancellationToken); });
75-
//taskManager.StartNew("Import", static async ctx =>
76-
//{
77-
// while (ctx.CancellationToken.IsCancellationRequested == false)
78-
// {
79-
// await Task.Delay(TimeSpan.FromSeconds(1));
80-
81-
// ctx.Task.ProgressValue += 2;
82-
83-
// if (ctx.Task.ProgressValue >= ctx.Task.ProgressMaxValue)
84-
// {
85-
// break;
86-
// }
87-
// }
88-
//});
70+
await api.InitAsync();
8971
}
9072

9173
/// <summary>

src/DragonFly.Permissions/Api/DragonFlyApiExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public static async Task AuthorizeAsync(this IDragonFlyApi api, string permissio
2525
IHttpContextAccessor httpContextAccessor = api.ServiceProvider.GetRequiredService<IHttpContextAccessor>();
2626
IAuthorizationService permissionService = api.ServiceProvider.GetRequiredService<IAuthorizationService>();
2727

28-
//temporary fix
28+
//temporary fix for background tasks
2929
if (httpContextAccessor.HttpContext == null)
3030
{
3131
return;

src/DragonFly.Proxy.Tests/DragonFly.Proxy.Tests.csproj

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
</ItemGroup>
1717

1818
<ItemGroup>
19-
<ProjectReference Include="..\..\DragonFly.Proxy.Generators\DragonFly.Proxy.Generators.csproj"
20-
OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
2119
<ProjectReference Include="..\DragonFly.Proxy\DragonFly.Proxy.csproj" />
2220
</ItemGroup>
2321
</Project>

src/DragonFly.sln

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Proxy", "Proxy", "{73422C53
9292
EndProject
9393
Project("{E53339B2-1760-4266-BCC7-CA923CBCF16C}") = "docker-compose", "docker-compose.dcproj", "{8D4355AF-19A7-471A-AA20-42052FCD042A}"
9494
EndProject
95-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DragonFly.Proxy.Generators", "..\DragonFly.Proxy.Generators\DragonFly.Proxy.Generators.csproj", "{B053FFE1-55BE-48FB-A189-6722B9E4C1E4}"
96-
EndProject
9795
Global
9896
GlobalSection(SolutionConfigurationPlatforms) = preSolution
9997
Debug|Any CPU = Debug|Any CPU
@@ -212,10 +210,6 @@ Global
212210
{8D4355AF-19A7-471A-AA20-42052FCD042A}.Debug|Any CPU.Build.0 = Debug|Any CPU
213211
{8D4355AF-19A7-471A-AA20-42052FCD042A}.Release|Any CPU.ActiveCfg = Release|Any CPU
214212
{8D4355AF-19A7-471A-AA20-42052FCD042A}.Release|Any CPU.Build.0 = Release|Any CPU
215-
{B053FFE1-55BE-48FB-A189-6722B9E4C1E4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
216-
{B053FFE1-55BE-48FB-A189-6722B9E4C1E4}.Debug|Any CPU.Build.0 = Debug|Any CPU
217-
{B053FFE1-55BE-48FB-A189-6722B9E4C1E4}.Release|Any CPU.ActiveCfg = Release|Any CPU
218-
{B053FFE1-55BE-48FB-A189-6722B9E4C1E4}.Release|Any CPU.Build.0 = Release|Any CPU
219213
EndGlobalSection
220214
GlobalSection(SolutionProperties) = preSolution
221215
HideSolutionNode = FALSE
@@ -257,7 +251,6 @@ Global
257251
{CA8FEA67-C9C2-4B21-9FD9-31BF3A813122} = {73422C53-BD4F-4D9F-84D1-A41F12AF0B91}
258252
{E9AFBCFA-1DA9-475A-8F7C-4733EEB102AC} = {551D7A23-7864-4CA8-B1F1-A58B25EA210E}
259253
{73422C53-BD4F-4D9F-84D1-A41F12AF0B91} = {551D7A23-7864-4CA8-B1F1-A58B25EA210E}
260-
{B053FFE1-55BE-48FB-A189-6722B9E4C1E4} = {73422C53-BD4F-4D9F-84D1-A41F12AF0B91}
261254
EndGlobalSection
262255
GlobalSection(ExtensibilityGlobals) = postSolution
263256
SolutionGuid = {069E83C9-3430-4D62-843B-B52982C42093}

0 commit comments

Comments
 (0)