向容器注入IEventProvider和ICommandClient,方便向星尘平台上报日志,以及注册应用命令(星尘平台或其它应用可向当前应用发送命令触发对应方法)
This commit is contained in:
parent
83094ec857
commit
1f890054a5
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
|
@ -11,6 +12,7 @@ using NewLife.Caching;
|
|||
using NewLife.Configuration;
|
||||
using NewLife.Log;
|
||||
using NewLife.Reflection;
|
||||
using NewLife.Remoting.Clients;
|
||||
using Stardust;
|
||||
using Stardust.Extensions;
|
||||
|
||||
|
@ -44,6 +46,8 @@ public static class StarFactoryExtensions
|
|||
services.AddSingleton(p => star.Tracer ?? DefaultTracer.Instance ?? (DefaultTracer.Instance ??= new DefaultTracer()));
|
||||
//services.AddSingleton(p => star.Config);
|
||||
services.AddSingleton(p => star.Service!);
|
||||
services.AddSingleton(p => (star.Service as IEventProvider)!);
|
||||
services.AddSingleton(p => (star.Service as ICommandClient)!);
|
||||
|
||||
// 替换为混合配置提供者,优先本地配置
|
||||
//services.Replace(new ServiceDescriptor(typeof(IConfigProvider), p => star.Config, ServiceLifetime.Singleton));
|
||||
|
|
|
@ -254,6 +254,8 @@ public class StarFactory : DisposeBase
|
|||
container.AddSingleton(this);
|
||||
container.AddSingleton(p => Tracer ?? DefaultTracer.Instance ?? (DefaultTracer.Instance ??= new DefaultTracer()));
|
||||
container.AddSingleton(p => Service!);
|
||||
container.AddSingleton(p => (p.GetService<IRegistry>() as IEventProvider)!);
|
||||
container.AddSingleton(p => (p.GetService<IRegistry>() as ICommandClient)!);
|
||||
|
||||
// 替换为混合配置提供者,优先本地配置
|
||||
container.AddSingleton(p => GetConfig()!);
|
||||
|
|
Loading…
Reference in New Issue