public void WebSite_Constructor_Initialises_To_Known_State_And_Properties_Work() { _WebSite = Factory.Resolve <IWebSite>(); Assert.IsNull(_WebSite.WebServer); TestUtilities.TestProperty(_WebSite, "BaseStationDatabase", null, _BaseStationDatabase.Object); TestUtilities.TestProperty(_WebSite, "StandingDataManager", null, _StandingDataManager.Object); }
private void Settings_FormClosing(object sender, FormClosingEventArgs e) { SortedDictionary <string, IProgram> DB = new SortedDictionary <string, IProgram>(); foreach (KeyValuePair <int, IProgram> ge in database) { IProgram program = ge.Value; if (!program.Name.Equals("PLEASE_SET")) { DB[program.Name.ToLower().Trim()] = program; } } SortedDictionary <string, IWebSite> DB2 = new SortedDictionary <string, IWebSite>(); foreach (KeyValuePair <int, IWebSite> ge in sites) { IWebSite program = ge.Value; if (!program.Name.Equals("PLEASE_SET")) { DB2[program.Name.ToLower().Trim()] = program; } } ConfigManager.Instance.setKnownWebsites(DB2); ConfigManager.Instance.setKnownPrograms(DB); ConfigManager.Instance.SaveDb(); }
/// <summary> /// Creates a new object. /// </summary> /// <param name="flightSimulatorAircraftList"></param> /// <param name="uPnpManager"></param> /// <param name="webSite"></param> /// <param name="pluginFolder"></param> public PluginStartupParameters(ISimpleAircraftList flightSimulatorAircraftList, IUniversalPlugAndPlayManager uPnpManager, IWebSite webSite, string pluginFolder) { FlightSimulatorAircraftList = flightSimulatorAircraftList; UPnpManager = uPnpManager; WebSite = webSite; PluginFolder = pluginFolder; }
public WebSite(IWebSite site) { FtpPassword = site.FtpPassword; FtpUri = site.FtpUri; FtpUsername = site.FtpUsername; WebSiteUri = site.WebSiteUri; }
private void StartPlugins(IWebSite webSite) { _View.ReportProgress(Strings.SplashScreenStartingPlugins); foreach (var plugin in Factory.ResolveSingleton <IPluginManager>().LoadedPlugins) { try { var parameters = new PluginStartupParameters( _View.FlightSimulatorXAircraftList, _View.UPnpManager, webSite, plugin.PluginFolder); plugin.Startup(parameters); if (BackgroundThreadExceptionHandler != null) { IBackgroundThreadExceptionCatcher backgroundExceptionCatcher = plugin as IBackgroundThreadExceptionCatcher; if (backgroundExceptionCatcher != null) { backgroundExceptionCatcher.ExceptionCaught += BackgroundThreadExceptionHandler; } } } catch (Exception ex) { Debug.WriteLine(String.Format("MainPresenter.StartPlugins caught exception: {0}", ex.ToString())); Factory.ResolveSingleton <ILog>().WriteLine("Caught exception when starting {0}: {1}", plugin.Name, ex.ToString()); _View.ReportProblem(String.Format(Strings.PluginThrewExceptionFull, plugin.Name, ex.Message), Strings.PluginThrewExceptionTitle, false); } } }
private void DOWORK() { if (this.InvokeRequired) { this.BeginInvoke((MethodInvoker) delegate { DOWORK(); }); return; } jProgressSpinner1.Visible = true; block = true; SortedDictionary <string, IProgram> DB = ConfigManager.Instance.knownPrograms(); SortedDictionary <string, IWebSite> DB2 = ConfigManager.Instance.knownSearch(); listBox_items.Rows.Clear(); jDataGrid1.Rows.Clear(); int id = 0; foreach (KeyValuePair <string, IProgram> ge in DB) { IProgram program = ge.Value; database[id] = program; listBox_items.Rows.Add(new object[] { id, program.Name, program.Path, program.Parameters }); id++; } id = 0; foreach (KeyValuePair <string, IWebSite> ge in DB2) { IWebSite program = ge.Value; sites[id] = program; jDataGrid1.Rows.Add(new object[] { id, program.Name, program.Url, program.Parameters }); id++; } block = false; jProgressSpinner1.Visible = false; }
/// <summary> /// Creates a new object. /// </summary> /// <param name="baseStationAircraftList"></param> /// <param name="flightSimulatorAircraftList"></param> /// <param name="uPnpManager"></param> /// <param name="webSite"></param> public PluginStartupParameters(IBaseStationAircraftList baseStationAircraftList, ISimpleAircraftList flightSimulatorAircraftList, IUniversalPlugAndPlayManager uPnpManager, IWebSite webSite) { AircraftList = baseStationAircraftList; FlightSimulatorAircraftList = flightSimulatorAircraftList; UPnpManager = uPnpManager; WebSite = webSite; }
public void TestInitialise() { _OriginalContainer = Factory.TakeSnapshot(); _WebServer = new Mock <IWebServer>() { DefaultValue = DefaultValue.Mock }.SetupAllProperties(); _Request = new Mock <IRequest>() { DefaultValue = DefaultValue.Mock }.SetupAllProperties(); _Response = new Mock <IResponse>() { DefaultValue = DefaultValue.Mock }.SetupAllProperties(); _InstallerSettingsStorage = TestUtilities.CreateMockImplementation <IInstallerSettingsStorage>(); _InstallerSettings = new InstallerSettings(); _InstallerSettingsStorage.Setup(m => m.Load()).Returns(_InstallerSettings); _SharedConfiguration = TestUtilities.CreateMockSingleton <ISharedConfiguration>(); _Configuration = new Configuration(); _Configuration.GoogleMapSettings.WebSiteReceiverId = 1; _Configuration.GoogleMapSettings.ClosestAircraftReceiverId = 1; _SharedConfiguration.Setup(r => r.Get()).Returns(_Configuration); _RuntimeEnvironment = TestUtilities.CreateMockSingleton <IRuntimeEnvironment>(); _RuntimeEnvironment.Setup(r => r.IsMono).Returns(false); _RuntimeEnvironment.Setup(r => r.ExecutablePath).Returns(TestContext.TestDeploymentDir); _BaseStationDatabase = new Mock <IBaseStationDatabase>() { DefaultValue = DefaultValue.Mock }.SetupAllProperties(); _AutoConfigBaseStationDatabase = TestUtilities.CreateMockSingleton <IAutoConfigBaseStationDatabase>(); _AutoConfigBaseStationDatabase.Setup(a => a.Database).Returns(_BaseStationDatabase.Object); _StandingDataManager = TestUtilities.CreateMockSingleton <IStandingDataManager>(); _UserManager = TestUtilities.CreateMockSingleton <IUserManager>(); _LoopbackHost = TestUtilities.CreateMockImplementation <ILoopbackHost>(); _LoopbackEnvironment = null; _LoopbackPathAndFile = null; _LoopbackResponse = new SimpleContent() { Content = new byte[0], HttpStatusCode = HttpStatusCode.OK, }; _LoopbackHost.Setup(r => r.SendSimpleRequest(It.IsAny <string>(), It.IsAny <IDictionary <string, object> >())).Returns((string p, IDictionary <string, object> e) => { _LoopbackPathAndFile = p; _LoopbackEnvironment = e; return(_LoopbackResponse); }); _FileSystemServerConfiguration = TestUtilities.CreateMockSingleton <IFileSystemServerConfiguration>(); _WebSite = Factory.Resolve <IWebSite>(); }
public WebSiteEntity(IWebSite site) : this() { WebSite = site.WebSiteUri.AbsoluteUri; FtpSite = site.FtpUri.AbsoluteUri; FtpUsername = site.FtpUsername; FtpPassword = site.FtpPassword; }
public static WebPage CreateInstance(this Type t, IWebSite parent) { var instance = (WebPage)Activator.CreateInstance(t); instance.DriverName = parent.DriverName; instance.Parent = parent; return(instance); }
/// <summary> /// See interface docs. /// </summary> /// <param name="webSite"></param> /// <param name="webPathAndFileName"></param> /// <param name="useImageCache"></param> /// <returns></returns> public Image LoadFromWebSite(IWebSite webSite, string webPathAndFileName, bool useImageCache) { Image result = null; if (!useImageCache) { result = FetchFromWebSite(webSite, webPathAndFileName); } else { var normalisedName = NormaliseWebPath(webPathAndFileName); CacheEntry cacheEntry; lock (_SyncLock) { _WebSiteImageCache.TryGetValue(normalisedName, out cacheEntry); if (cacheEntry != null && cacheEntry.LastFetchedUtc >= _Clock.UtcNow.AddSeconds(-WebSiteCacheExpirySeconds)) { if (cacheEntry.Image != null) { result = new Bitmap(cacheEntry.Image); } } } if (cacheEntry == null || (cacheEntry.Image != null && result == null)) { // This can lead to double-fetches, however I would rather have those than have multiple threads block while images are // being fetched serially. result = FetchFromWebSite(webSite, webPathAndFileName); cacheEntry = new CacheEntry() { Image = result == null ? null : new Bitmap(result), LastFetchedUtc = _Clock.UtcNow, NormalisedFileName = normalisedName, }; lock (_SyncLock) { CacheEntry oldEntry; if (!_WebSiteImageCache.TryGetValue(normalisedName, out oldEntry)) { _WebSiteImageCache.Add(normalisedName, cacheEntry); } else { if (oldEntry.Image != null) { oldEntry.Image.Dispose(); oldEntry.Image = null; } _WebSiteImageCache[normalisedName] = cacheEntry; } } } } return(result); }
public StudentWithSite(IStudent student, IWebSite site) : base(student) { if (site != null) { WebSiteUri = site.WebSiteUri; FtpUri = site.FtpUri; FtpUsername = site.FtpUsername; FtpPassword = site.FtpPassword; } }
public void AddWebSite(ICourse course, IStudent student, IWebSite webSite) { var entity = new WebSiteEntity(webSite); var insert = TableOperation.Insert(entity); resourceTable.Execute(insert); var linkEntity = new JoinEntity(course.ResourceKey(student), entity.RowKey); mapTable.Execute(TableOperation.Insert(linkEntity)); }
static void Main(string[] args) { Developer dev = new NetDeveloper("Manolii"); dev.SomeOperation(); Developer dev2 = new JavaDeveloper("Mykola"); IWebSite javaSite = dev2.CreateWebSite(); Console.ReadLine(); }
/// <summary> /// See interface docs. /// </summary> /// <param name="parameters"></param> public void Startup(PluginStartupParameters parameters) { Singleton = this; _WebSite = parameters.WebSite; var options = OptionsStorage.Load(this); ApplyOptions(options); var heartbeat = Factory.ResolveSingleton <IHeartbeatService>(); heartbeat.SlowTick += Heartbeat_SlowTick; }
/// <summary> /// Disposes of or finalises the object. /// </summary> /// <param name="disposing"></param> protected virtual void Dispose(bool disposing) { if (disposing) { Enabled = false; if (_WebServer != null) { _WebServer.BeforeRequestReceived -= WebServer_BeforeRequestReceived; _WebServer = null; } _WebSite = null; } }
/// <summary> /// See interface docs. /// </summary> /// <param name="pluginStartupParameters"></param> public void Initialise(PluginStartupParameters pluginStartupParameters) { _WebSite = pluginStartupParameters.WebSite; if (!String.IsNullOrEmpty(WebRootSubFolder)) { _SiteRoot = new SiteRoot() { Folder = Path.Combine(pluginStartupParameters.PluginFolder, WebRootSubFolder), Priority = Priority, }; } if (!String.IsNullOrEmpty(InjectContent)) { var injectContent = InjectContent; Func <string, HtmlContentInjector> createInjector = (string pathAndFile) => new HtmlContentInjector() { Content = () => injectContent, Element = "HEAD", PathAndFile = pathAndFile, Priority = Priority, }; if (InjectPages.Count == 0) { _ContentInjectors.Add(createInjector(null)); } else { foreach (var injectPage in InjectPages) { _ContentInjectors.Add(createInjector(injectPage)); } } } if (PageHandlers.Count > 0) { _WebServer = Factory.Singleton.Resolve <IAutoConfigWebServer>().Singleton.WebServer; _WebServer.BeforeRequestReceived += WebServer_BeforeRequestReceived; foreach (var pageHandler in PageHandlers) { _PageHandlers.Add(pageHandler.Key, pageHandler.Value); } } EnableDisableContent(); }
/// <summary> /// Hooks the manager into the web site. /// </summary> /// <param name="webSite"></param> public void Startup(IWebSite webSite) { if (_WebSite != null) { throw new InvalidOperationException("Only call Startup once"); } lock (_SyncLock) { _WebSite = webSite; _WebSite.WebServer.RequestReceived += WebServer_RequestReceived; _WebSite.WebServer.RequestFinished += WebServer_RequestFinished; _WebSite.HtmlLoadedFromFile += WebSite_HtmlLoadedFromFile; EnableDisableSiteRoots(); } }
/// <summary> /// Fetches an image from the web site passed across. /// </summary> /// <param name="webSite"></param> /// <param name="webPathAndFileName"></param> /// <returns></returns> private Image FetchFromWebSite(IWebSite webSite, string webPathAndFileName) { Image result = null; var simpleContent = webSite.RequestSimpleContent(webPathAndFileName); if (simpleContent != null && simpleContent.HttpStatusCode == System.Net.HttpStatusCode.OK) { using (var memoryStream = new MemoryStream(simpleContent.Content)) { using (var image = Image.FromStream(memoryStream)) { result = new Bitmap(image); // work around the problem that GDI+ has with images built from streams being accessed after the stream has been disposed } } } return(result); }
private void toolStripMenuItem1_Click(object sender, EventArgs e) { if (block) { return; } if (sites != null) { IWebSite program = new IWebSite(); program.Name = "PLEASE_SET"; int nextK = 0; try { nextK = sites.Keys.Last() + 1; } catch { } sites.Add(nextK, program); jDataGrid1.Rows.Add(new object[] { nextK, program.Name, program.Url, program.Parameters }); } }
public RouterManager() { _logger = LogManager.GetCurrentClassLogger(); _logger.Trace("Creating RouteManager"); _config = new Config(); _homePageUrl = _config.BaseUrl + "/html/home.html"; _publicRsaKeyUrl = _config.BaseUrl + "/api/webserver/publickey"; _loginPageUrl = _config.BaseUrl + "/api/user/login"; _networkChangeUrl = _config.BaseUrl + "/api/net/net-mode"; _connectionStatusUrl = _config.BaseUrl + "/api/monitoring/status"; _logger.Trace("Initializing JS engine"); InitJsEngine(); _logger.Trace("Initializing JS engine... Done"); _website = new WebSite(); _logger.Trace("Creating RouteManager... Done"); IsInitialized = true; }
/// <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); } }
private void StartPlugins(IWebSite webSite) { _View.ReportProgress(Strings.SplashScreenStartingPlugins); var parameters = new PluginStartupParameters( _View.BaseStationAircraftList, _View.FlightSimulatorXAircraftList, _View.UPnpManager, webSite); foreach(var plugin in Factory.Singleton.Resolve<IPluginManager>().Singleton.LoadedPlugins) { try { plugin.Startup(parameters); if(BackgroundThreadExceptionHandler != null) { IBackgroundThreadExceptionCatcher backgroundExceptionCatcher = plugin as IBackgroundThreadExceptionCatcher; if(backgroundExceptionCatcher != null) backgroundExceptionCatcher.ExceptionCaught += BackgroundThreadExceptionHandler; } } catch(Exception ex) { Debug.WriteLine(String.Format("MainPresenter.StartPlugins caught exception: {0}", ex.ToString())); Factory.Singleton.Resolve<ILog>().Singleton.WriteLine("Caught exception when starting {0}: {1}", plugin.Name, ex.ToString()); _View.ReportProblem(String.Format(Strings.PluginThrewExceptionFull, plugin.Name, ex.Message), Strings.PluginThrewExceptionTitle, false); } } }
public void AddWebsite(string key, IWebSite program) { configs.websites[key] = program; }
/// <summary> /// See interface docs. /// </summary> /// <param name="webSite"></param> /// <param name="webPathAndFileName"></param> /// <param name="useImageCache"></param> /// <returns></returns> public Image LoadFromWebSite(IWebSite webSite, string webPathAndFileName, bool useImageCache) { return(LoadFromSiteOrCache(webPathAndFileName, useImageCache, () => FetchFromWebSite(webSite, webPathAndFileName))); }
/// <summary> /// Fetches an image from the web site passed across. /// </summary> /// <param name="webSite"></param> /// <param name="webPathAndFileName"></param> /// <returns></returns> private Image FetchFromWebSite(IWebSite webSite, string webPathAndFileName) { return(ExtractFromSimpleContent(webSite.RequestSimpleContent(webPathAndFileName))); }
public HomeController(IWebSite webSite) { this.webSiteServer = webSite; }