コード例 #1
0
ファイル: UModLogger.cs プロジェクト: NickRimmer/RustApi
        public UModLogger(RustApiOptions options)
        {
            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }

            _logLevel  = options.LogLevel;
            _logToFile = options.LogToFile;
        }
コード例 #2
0
ファイル: RustApiServices.cs プロジェクト: NickRimmer/RustApi
        /// <summary>
        /// Read options method.
        /// </summary>
        /// <param name="container">Services container.</param>
        /// <param name="configFileName">Configuration file name.</param>
        /// <returns></returns>
        private static RustApiOptions GetApiOptions(MicroContainer container)
        {
            var options = OptionsManager.ReadOptions <RustApiOptions>(ConfigFileName, container);

            if (options == default)
            {
                options = new RustApiOptions(DefaultEndpoint);
                OptionsManager.WriteOptions(ConfigFileName, options, container);
            }

            return(options);
        }
コード例 #3
0
        public ApiServer(
            RustApiOptions options,
            ILogger <ApiServer> logger,
            IAuthenticationService authenticationService,
            IApiRoutes apiRoutes)
        {
            _options = options ?? throw new ArgumentNullException(nameof(options));
            _logger  = logger ?? throw new ArgumentNullException(nameof(logger));
            _authenticationService = authenticationService ?? throw new ArgumentNullException(nameof(authenticationService));
            _apiRoutes             = apiRoutes ?? throw new ArgumentNullException(nameof(apiRoutes));
            _listener = new HttpListener();

            SetupListener();
        }