⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 formattingpipeline.cs

📁 YetAnotherForum.Net+ScrewTurnWiki中文完美汉化增强版
💻 CS
字号:

using System;
using System.Collections.Generic;
using ScrewTurn.Wiki.PluginFramework;
using System.Web;

namespace ScrewTurn.Wiki {

	/// <summary>
	/// Contains methods for formatting content using a pipeline paradigm.
	/// </summary>
	public static class FormattingPipeline {

		/// <summary>
		/// Performs the Phases 1 and 2 of the formatting process.
		/// </summary>
		/// <param name="raw">The Raw WikiMarkup to format.</param>
		/// <param name="current">The current Page, if any.</param>
		/// <returns>The formatted content.</returns>
		public static string FormatWithPhase1And2(string raw, PageInfo current) {
			PageInfo[] tmp;
			return FormatWithPhase1And2(raw, current, out tmp);
		}

		/// <summary>
		/// Performs the Phases 1 and 2 of the formatting process.
		/// </summary>
		/// <param name="raw">The Raw WikiMarkup to format.</param>
		/// <param name="current">The current Page, if any.</param>
		/// <param name="linkedPages">The Pages linked by the current Page.</param>
		/// <returns>The formatted content.</returns>
		public static string FormatWithPhase1And2(string raw, PageInfo current, out PageInfo[] linkedPages) {
			ContextInformation info = null;
			string username = SessionFacade.Username;
			bool admin = false;
			try {
				admin = SessionFacade.Admin;
			}
			catch {}
			info = new ContextInformation(current, System.Threading.Thread.CurrentThread.CurrentCulture.Name, HttpContext.Current, username, admin);

			// Phase 1
			for(int i = 0; i < Collectors.FormatterProviderCollector.AllProviders.Length; i++) {
				if(Collectors.FormatterProviderCollector.AllProviders[i].PerformPhase1) {
					raw = Collectors.FormatterProviderCollector.AllProviders[i].Format(raw, info, FormattingPhase.Phase1);
				}
			}

			PageInfo[] lnk;

			raw = Formatter.Format(raw, current, out lnk);

			// Phase 2
			for(int i = 0; i < Collectors.FormatterProviderCollector.AllProviders.Length; i++) {
				if(Collectors.FormatterProviderCollector.AllProviders[i].PerformPhase2) {
					raw = Collectors.FormatterProviderCollector.AllProviders[i].Format(raw, info, FormattingPhase.Phase2);
				}
			}

			linkedPages = lnk;

			return raw;
		}

		/// <summary>
		/// Performs the Phase 3 of the formatting process.
		/// </summary>
		/// <param name="raw">The Raw WikiMarkup to format.</param>
		/// <param name="current">The current Page, if any.</param>
		/// <returns>The formatted content.</returns>
		public static string FormatWithPhase3(string raw, PageInfo current) {
			raw = Formatter.FormatPhase3(raw, current);

			ContextInformation info = null;
			string username = SessionFacade.Username;
			bool admin = false;
			try {
				admin = SessionFacade.Admin;
			}
			catch { }
			info = new ContextInformation(current, System.Threading.Thread.CurrentThread.CurrentCulture.Name, HttpContext.Current, username, admin);

			// Phase 3
			for(int i = 0; i < Collectors.FormatterProviderCollector.AllProviders.Length; i++) {
				if(Collectors.FormatterProviderCollector.AllProviders[i].PerformPhase3) {
					raw = Collectors.FormatterProviderCollector.AllProviders[i].Format(raw, info, FormattingPhase.Phase3);
				}
			}

			return raw;
		}

	}

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -