Comments (3)
这个不需要干预,配置文件中的iocDll 是为了让ioc 容器扫描程序集加入ioc容器。现在 模块之间有依赖可以参考这个示例https://github.com/duyanming/Anno.Core/blob/master/samples/Packages/Anno.Plugs.SoEasyService/SoEasyBootStrap.cs
from anno.core.
using Anno.EngineData;
using System;
namespace Anno.Plugs.SoEasyService
{
///
/// 插件启动引导器
/// DependsOn 依赖的类型程序集自动注入DI容器
///
[DependsOn(
typeof(SoEasy.Application.AppBootstrap)
//typeof(Domain.Bootstrap)
//, typeof(QueryServices.Bootstrap)
//, typeof(Repository.Bootstrap)
//, typeof(Command.Handler.Bootstrap
)]
public class SoEasyBootStrap : IPlugsConfigurationBootstrap
{
///
/// Service 依赖注入构建之后调用
///
public void ConfigurationBootstrap()
{
//throw new NotImplementedException();
}
///
/// Service 依赖注入构建之前调用
///
///
public void PreConfigurationBootstrap()
{
//throw new NotImplementedException();
}
}
}
from anno.core.
对哥写架构有兴趣,所以想了解一下如何设计
/// <summary>
/// 服务集
/// </summary>
public static class Assemblys
{
/// <summary>
/// 服务集合
/// </summary>
public static readonly Dictionary<string, Assembly> Dic = new Dictionary<string, Assembly>();
/// <summary>
/// Ioc模块DLL列表
/// </summary>
public static List<Assembly> DependedTypes { get; set; } = new List<Assembly>();
}
public static class AppSettings
{
/// <summary>
/// 数据库连接字符串
/// </summary>
public static String ConnStr { get; set; }
/// <summary>
/// 用户重置密码的时候的默认密码
/// </summary>
public static String DefaultPwd { get; set; } = "Anno";
/// <summary>
/// Ioc插件DLL列表
/// </summary>
public static List<string> IocDll { get; set; } = new List<string>();
}
AppSettings 的 Add IocDll
- 透过 Anno.config 的 IocDll/Assembly
- 透过 Anno.config 的
- 根目录 Anno.Plugs.{xxx}Service.dll
- Packages/ 里面的 Anno.Plugs.{xxx}Service.dll
- 单文件
Assemblys 的 Dic
- 透过 Anno.config 的
- 根目录 Anno.Plugs.{xxx}Service.dll
- Packages/ 里面的 Anno.Plugs.{xxx}Service.dll
- 单文件
RegisterIoc 透过 AppSettings.IocDll 参数, 去将实体注入容器为什么不用直接用 Const.Assemblys.Dic
public static IServiceCollection UseDependencyInjection(this IServiceCollection services)
{
//已经加载过的不再重新加载
if (loader)
{
return services;
}
Const.AppSettings.IocDll.Distinct().ToList().ForEach(d =>
{
RegisterAssembly(services, Const.Assemblys.Dic[d]);
});
foreach (var assembly in Const.Assemblys.DependedTypes)
{
RegisterAssembly(services, assembly);
}
loader = true;
return services;
}
因为底下 PreConfigurationBootstrap 也是直接使用 Const.Assemblys.Dic
/// <summary>
/// IOC注入之前插件事件
/// </summary>
private static void PreConfigurationBootstrap()
{
foreach (var svc in Const.Assemblys.Dic)
{
InvokeDependedTypesAssemblies(svc.Value);
}
}
from anno.core.
Related Issues (8)
- 生成dump文件 HOT 1
- 请问如何配置内网穿透下的IP与端口? HOT 1
- 注册中心服务信息变更自定义回调(发短信或者发邮件) HOT 1
- 使用 TopShelf 注册为Windows服务
- 服务发现配置 HOT 1
- 看了一下代码,感觉有点闭门造车的感觉 HOT 4
- 请问是否支持Maui下的安卓客户端访问后台服务模式? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from anno.core.