Esempio n. 1
0
 /// <summary>
 /// 启用Nlog日志扩展方法,日志配置参数查看nlog.config文件
 /// </summary>
 /// <param name="webHostBuilder"></param>
 /// <returns></returns>
 public static IWebHostBuilder UseNLoger(this IWebHostBuilder webHostBuilder) =>
 AspNetExtensions.UseNLog(webHostBuilder.ConfigureLogging((webHostBuilderContext, logging) =>
 {
     logging.AddFilter("System", LogLevel.Warning);    //不记录系统自带的异常日志
     logging.AddFilter("Microsoft", LogLevel.Warning); //不记录微软自带的异常日志
     logging.ClearProviders();
     logging.SetMinimumLevel(LogLevel.Trace);
 }));
        /// <summary>
        ///  注册assemblies集合中继承自NalongDomainService的类,注意自定义DomainService不需要新增接口
        /// </summary>
        /// <param name="services"></param>
        /// <param name="assemblies"></param>
        public static void AddDomainService(this IServiceCollection services, params Assembly[] assemblies)
        {
            var list = new List <Type>();

            foreach (var assembly in assemblies)
            {
                list = list.Union(assembly.GetTypes().ToList()).ToList();
            }

            var mappers = AspNetExtensions.GetServicesMapper <IDomainService>(list);

            foreach (var item in mappers)
            {
                services.AddScoped(item.Key);
            }
        }
 public static IWebHostBuilder UseEvoLog(this IWebHostBuilder builder)
 {
     return(AspNetExtensions.UseNLog(builder));
 }
        public void RetrieveUserName_NullUser_YieldsNull()
        {
            var createdUsername = AspNetExtensions.RetrieveUsername(null);

            Assert.IsNull(createdUsername);
        }