1. App 静态类

1.1 获取全局配置#

var settings = App.Settings;

1.2 获取配置对象#

var configuration = App.Configuration;
var data = App.GetConfig<TConfig>("key:key2");

1.3 获取环境对象#

var webHostEnvironment = App.WebHostEnvironment;

1.4 获取项目所有程序集#

var assemblies = App.Assemblies;

1.5 获取项目所有有效类型#

var types = App.EffectiveTypes;

1.6 获取 HttpContext#

var httpContext = App.HttpContext;

1.7 获取登录的 User 对象#

var contextUser = App.User;

1.8 获取服务提供器#

var serviceProvider = App.ServiceProvider;

1.9 解析服务#

var service = App.GetService<TService>();
var service2 = App.GetService(typeof(TService));
var service3 = App.GetRequiredService<TService>();
var service4 = App.GetRequiredService(typeof(TService));

1.10 获取选项配置#

var options = App.GetOptions<TOptions>();
var options2 = App.GetOptionsMonitor<TOptions>();
var options3 = App.GetOptionsSnapshot<TOptions>();

1.11 打印数据到 MiniProfiler#

App.PrintToMiniProfiler("分类", "状态", "要打印的消息");