Skip to content

Commit

Permalink
向调度器添加处理器时,即时从ioc解析对象,支持处理器的构造函数注入。#15
Browse files Browse the repository at this point in the history
  • Loading branch information
nnhy committed Oct 29, 2024
1 parent 09c0217 commit 0093c48
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 16 deletions.
2 changes: 1 addition & 1 deletion AntJob.Agent/AntJob.Agent.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="NewLife.Stardust" Version="3.1.2024.1004" />
<PackageReference Include="NewLife.Stardust" Version="3.1.2024.1025-beta1552" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion AntJob.Data/AntJob.Data.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<None Remove="Build.tt" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="NewLife.XCode" Version="11.16.2024.1005" />
<PackageReference Include="NewLife.XCode" Version="11.16.2024.1027-beta0304" />
</ItemGroup>
<ItemGroup>
<None Update="Build.log">
Expand Down
2 changes: 1 addition & 1 deletion AntJob.Extensions/AntJob.Extensions.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="NewLife.XCode" Version="11.16.2024.1005" />
<PackageReference Include="NewLife.XCode" Version="11.16.2024.1027-beta0304" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\AntJob\AntJob.csproj" />
Expand Down
2 changes: 1 addition & 1 deletion AntJob.Server/AntJob.Server.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<Content Include="favicon.ico" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="NewLife.Redis" Version="6.0.2024.1006" />
<PackageReference Include="NewLife.Redis" Version="6.0.2024.1022-beta1409" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\AntJob.Data\AntJob.Data.csproj" />
Expand Down
6 changes: 3 additions & 3 deletions AntJob.Web/AntJob.Web.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@
<Content Include="favicon.ico" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="NewLife.Cube.Core" Version="6.1.2024.1005" />
<PackageReference Include="NewLife.Remoting.Extensions" Version="3.0.2024.1002" />
<PackageReference Include="NewLife.Stardust.Extensions" Version="3.1.2024.1004" />
<PackageReference Include="NewLife.Cube.Core" Version="6.1.2024.1025-beta1556" />
<PackageReference Include="NewLife.Remoting.Extensions" Version="3.0.2024.1025-beta1552" />
<PackageReference Include="NewLife.Stardust.Extensions" Version="3.1.2024.1025-beta1552" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\AntJob.Data\AntJob.Data.csproj" />
Expand Down
6 changes: 3 additions & 3 deletions AntJob/AntJob.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="NewLife.Core" Version="11.0.2024.1001" />
<PackageReference Include="NewLife.Remoting" Version="3.1.2024.1002" />
<PackageReference Include="NewLife.Stardust" Version="3.1.2024.1004" />
<PackageReference Include="NewLife.Core" Version="11.0.2024.1029-beta0215" />
<PackageReference Include="NewLife.Remoting" Version="3.1.2024.1025-beta1552" />
<PackageReference Include="NewLife.Stardust" Version="3.1.2024.1025-beta1552" />
</ItemGroup>

<ItemGroup>
Expand Down
15 changes: 11 additions & 4 deletions AntJob/Scheduler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,18 @@ protected override void Dispose(Boolean disposing)
/// <typeparam name="T"></typeparam>
public void AddHandler<T>() where T : Handler
{
var services = ObjectContainer.Current;
var prv = ObjectContainer.Provider;
services.AddTransient<T>();
var prv = ServiceProvider;
if (prv == null)
{
var services = ObjectContainer.Current;
prv = ObjectContainer.Provider;
services.AddTransient<T>();
}

// 马上实例化
var handler = prv.GetService<T>() ?? prv.CreateInstance(typeof(T)) as T;

Handlers.Add(prv.GetService<T>());
Handlers.Add(handler);
}
#endregion

Expand Down
2 changes: 1 addition & 1 deletion Samples/HisData/HisData.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="NewLife.XCode" Version="11.16.2024.1005" />
<PackageReference Include="NewLife.XCode" Version="11.16.2024.1027-beta0304" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion Samples/HisWeb/HisWeb.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="NewLife.Cube.Core" Version="6.1.2024.1005" />
<PackageReference Include="NewLife.Cube.Core" Version="6.1.2024.1025-beta1556" />
</ItemGroup>

<ItemGroup>
Expand Down

0 comments on commit 0093c48

Please sign in to comment.