/// <summary> /// See interface docs. /// </summary> /// <param name="server"></param> public void AttachSiteToServer(IWebServer server) { if (server == null) { throw new ArgumentNullException("server"); } if (WebServer != server) { if (WebServer != null) { throw new InvalidOperationException("The web site can only be attached to one server"); } _UserManager = Factory.Singleton.Resolve <IUserManager>().Singleton; var configurationStorage = Factory.Singleton.Resolve <IConfigurationStorage>().Singleton; configurationStorage.ConfigurationChanged += ConfigurationStorage_ConfigurationChanged; WebServer = server; server.Root = "/VirtualRadar"; var installerSettingsStorage = Factory.Singleton.Resolve <IInstallerSettingsStorage>(); var installerSettings = installerSettingsStorage.Load(); server.Port = installerSettings.WebServerPort; server.AuthenticationRequired += Server_AuthenticationRequired; _Bundler = Factory.Singleton.Resolve <IBundler>(); _Bundler.AttachToWebSite(this); _Minifier = Factory.Singleton.Resolve <IMinifier>(); _Minifier.Initialise(); _Pages.Add(_CorsPreflightPage); _Pages.Add(_FileSystemPage); _Pages.Add(new TextPage(this)); _Pages.Add(_AircraftListJsonPage); _Pages.Add(_ImagePage); _Pages.Add(new ServerConfigJsonPage(this)); _Pages.Add(new AudioPage(this)); _Pages.Add(new FaviconPage(this)); _Pages.Add(_ReportRowsJsonPage); _Pages.Add(_ClosestAircraftJsonPage); _Pages.Add(new AirportDataProxyPage(this)); _Pages.Add(new PolarPlotJsonPage(this)); _Pages.Add(new DirectoryEntryJsonPage(this)); _JavaScriptInjectors.Add(new WebSiteStringsInjector()); foreach (var page in _Pages) { page.Provider = Provider; } LoadConfiguration(); server.RequestReceived += Server_RequestReceived; } }
/// <summary> /// See interface docs. /// </summary> /// <param name="webSite"></param> public void AttachToWebSite(IWebSite webSite) { if (webSite == null) { throw new ArgumentNullException("webSite"); } if (webSite.WebServer == null) { throw new InvalidOperationException("The web site must be attached to a web server before the bundler can use it"); } if (_WebServerHooked && WebServer != null) { WebServer.RequestReceived -= WebServer_RequestReceived; } if (_Minifier == null) { _Minifier = Factory.Singleton.Resolve <IMinifier>(); _Minifier.Initialise(); } WebSite = webSite; WebServer = webSite.WebServer; WebServer.RequestReceived += WebServer_RequestReceived; _WebServerHooked = true; if (!_ConfigurationStorageHooked) { var configurationStorage = Factory.Singleton.Resolve <IConfigurationStorage>().Singleton; configurationStorage.ConfigurationChanged += ConfigurationChanged; _ConfigurationStorageHooked = true; LoadConfiguration(configurationStorage); } }