コード例 #1
0
ファイル: Page.cs プロジェクト: MichaelFroelich/FAP.NET
		/// <summary>
		/// Internal function within FAP for marking pages as static pages, to be cloned for individual user page instances.
		/// Using this function is an incredibly bad idea.
		/// </summary>
		static internal void SetStatic(Page p)
		{
			if (p.PageCache == null) {
				p.isstatic = true;
				p.PageCache = new Dictionary<int, Page>();
			}
		}
コード例 #2
0
ファイル: Server.cs プロジェクト: MichaelFroelich/FAP.NET
		/// <summary>
		/// Adds a page, mostly
		/// </summary>
		/// <param name="p">Pages, single pages</param>
		public void AddPage(Page p)
		{
			if (p != null) {
				Page.SetStatic(p);
				pagelist.Add(p.Path, p);
			}
		}
コード例 #3
0
ファイル: Server.cs プロジェクト: MichaelFroelich/FAP.NET
		/// <summary>
		/// Removes a page, mostly
		/// </summary>
		/// <param name="p">Pages, single pages</param>
		public void RemovePage(Page p)
		{
			if (p != null && pagelist.ContainsKey(p.Path))
				pagelist.Remove(p.Path);
		}
コード例 #4
0
ファイル: Server.cs プロジェクト: MichaelFroelich/FAP.NET
		async void cacheAdd(int cacheVars, Page toAdd, Page parentPage)
		{
			try {
				parentPage.PageCache.Add(cacheVars, toAdd);
				while (toAdd != null) {
					await Task.Delay(CacheMaxAge);
					if (toAdd.PageAge > CacheMaxAge) {
						parentPage.PageCache.Remove(cacheVars);
						toAdd = null;
						break;
					}
				}
			} catch (Exception e) {
				Console.Error.WriteLine("02: " + DateTime.UtcNow + " Async Exception " + e.Message);
				if (parentPage != null && parentPage.PageCache != null && parentPage.PageCache.ContainsKey(cacheVars))
					parentPage.PageCache.Remove(cacheVars); //Oh the paranoia
			}
		}