protected override void OnStart(string[] args)
        {
            _logger.Information(
                "Starting service. BaseAddress='{BaseAddress}' JsonSettingsFile='{JsonSettingsFile}'",
                _baseAddress, _jsonSettingsFilePath);

            if (_app != null)
            {
                throw new InvalidOperationException("Service is already started.");
            }

            _app = WebApp.Start(_baseAddress, app =>
            {
                _logger.Information("Configuring WebApi.");

                var settings = LightNugetServerSettingsJsonFactory.Create(_jsonSettingsFilePath);
                var config   = new HttpConfiguration();

                app.UseLightNuGetServer(config, settings, feeds =>
                {
                    config.Services.Replace(typeof(IHttpControllerActivator), new LightNuGetFeedControllerActivator(feeds));
                });

                app.UseWebApi(config);
            });

            _logger.Information("Service started.");
        }
Esempio n. 2
0
            public void Start(string baseAddress, string jsonSettingsFilePath)
            {
                if (_app != null)
                {
                    throw new InvalidOperationException("Service is already started.");
                }

                _app = WebApp.Start(baseAddress, app =>
                {
                    var settings = LightNugetServerSettingsJsonFactory.Create(jsonSettingsFilePath);
                    var config   = new HttpConfiguration();

                    app.UseLightNuGetServer(config, settings, feeds =>
                    {
                        config.Services.Replace(typeof(IHttpControllerActivator), new LightNuGetFeedControllerActivator(feeds));
                    });

                    app.UseWebApi(config);
                });
            }