示例#1
0
        private static AppServerConfig GenServerConfig()
        {
            var signalrType =
                Environment.GetEnvironmentVariable(UseLocalSignalR) == null ||
                Environment.GetEnvironmentVariable(UseLocalSignalR) == "" ||
                Environment.GetEnvironmentVariable(UseLocalSignalR) == "false" ? 1 : 0;
            var config = new ConfigurationBuilder()
                         .SetBasePath(Directory.GetCurrentDirectory())
                         .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
                         .AddEnvironmentVariables()
                         .AddUserSecrets(UserSecrets)
                         .Build();
            var appConfig = new AppServerConfig()
            {
                SignalRType = signalrType
            };

            if (signalrType == 1)
            {
                var connectionString = config[ASRSConnectionStringKey];
                Console.WriteLine($"connection string: {connectionString}");
                appConfig.ConnectionString = connectionString;
                if (config[ASRSConnectionNumberKey] != null)
                {
                    appConfig.ConnectionNumber = config.GetValue <int>(ASRSConnectionNumberKey);
                }
            }
            return(appConfig);
        }
示例#2
0
 public Startup(AppServerConfig serverConfig)
 {
     _serverConfig           = serverConfig;
     Console.BackgroundColor = ConsoleColor.DarkMagenta;
     _useLocalSignalR        = _serverConfig.SignalRType == 0 ? true : false;
     Console.WriteLine($"use local signalr: {_useLocalSignalR}");
     Console.BackgroundColor = ConsoleColor.Black;
 }
示例#3
0
        private AppServerConfig GetAppServerConfig(ApplicationCommandOptions option)
        {
            var config = new AppServerConfig()
            {
                SignalRType         = option.SignalRType,
                AccessTokenLifetime = option.AccessTokenLifetime,
                ConnectionNumber    = option.ServerConnectionNumber,
                ConnectionString    = option.ConnectionString,
                MinLogLevel         = option.MinLogLevel
            };

            return(config);
        }
        public TimedLoggerFactory(AppServerConfig serverConfig)
        {
            _appServerConfig = serverConfig;
            var serviceCollection = new ServiceCollection();

            serviceCollection.AddLogging(config =>
            {
                config.AddConsole();
                config.SetMinimumLevel(serverConfig.MinLogLevel);
            });
            var serviceProvider = serviceCollection.BuildServiceProvider();

            _loggerFactory = serviceProvider.GetRequiredService <ILoggerFactory>();
        }