fix Add spark service modules designed for DependencyInjection
This commit is contained in:
1 parent
079826f4de
commit
d6f370f862
3 files changed
+6
-10
No files matched your search
@@ -9,6 +9,7 @@ using bts.api.position;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
using Spark.Api.Admin;
|
||||
using Spark.Api.Orders;
|
||||
using Spark.Api.Reactive;
|
||||
using Spark.Core.Services;
|
||||
@@ -22,7 +23,7 @@ public static class SparkApiServices {
|
||||
/// <returns>A reference to this instance after the operation has completed.</returns>
|
||||
public static IServiceCollection AddSparkd(this IServiceCollection services, IConfiguration configurationSection) {
|
||||
services.Configure<SparkdCredentials>(configurationSection.GetSection("Credentials"))
|
||||
.Configure<SparkConfig>(configurationSection.GetSection("Config"))
|
||||
.AddSpark(configurationSection.GetSection("Config"))
|
||||
.AddSingleton<ServiceContext>()
|
||||
.AddHostedService<SparkdLoginService>()
|
||||
.AddSparkdService<SecurityResolver>();
|
||||
@@ -35,6 +36,7 @@ public static class SparkApiServices {
|
||||
}
|
||||
if (configurationSection.GetValue("EnableAdmin", true)) {
|
||||
services.AddSparkdService<AdminService>();
|
||||
services.AddSparkdService<AdminClient>();
|
||||
}
|
||||
return services;
|
||||
}
|
||||
|
||||
@@ -4,8 +4,6 @@ namespace bts.api.core {
|
||||
|
||||
using Microsoft.Extensions.Options;
|
||||
|
||||
using Spark.Core.Services;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@@ -16,11 +14,7 @@ namespace bts.api.core {
|
||||
IntPtr _qbus;
|
||||
AuthToken? _token;
|
||||
|
||||
public ServiceContext(IOptions<SparkConfig> config)
|
||||
: this(config.Value) { }
|
||||
|
||||
public ServiceContext(SparkConfig config) {
|
||||
BTS.init(config.ConfigServer);
|
||||
public ServiceContext() {
|
||||
_qbus = ApiNativeMethods.api_create_quickbus(null, 0);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#nullable enable
|
||||
namespace Spark.Core.Services;
|
||||
|
||||
using bts;
|
||||
using mbts.config;
|
||||
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.Extensions.Options;
|
||||
@@ -17,7 +17,7 @@ public class SparkService : IHostedService {
|
||||
}
|
||||
|
||||
public Task StartAsync(CancellationToken cancellationToken) {
|
||||
BTS.init(config.ConfigServer);
|
||||
Configuration.initialize(config.ConfigServer);
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user