コード例 #1
0
		public void UpdateNamespaces(Federation aFed)
		{
			// just kill the old ones and reload new ones
			foreach (string each in NamespaceNames)
				aFed.UnregisterNamespace(aFed.ContentBaseForNamespace(each));
			LoadNamespaces(aFed);
		}
コード例 #2
0
ファイル: Formatter.cs プロジェクト: nuxleus/flexwiki
		/// <summary>
		/// Answer the formatted text for a given topic, formatted using a given OutputFormat and possibly showing diffs with the previous revision
		/// </summary>
		/// <param name="topic">The topic</param>
		/// <param name="format">What format</param>
		/// <param name="showDiffs">true to show diffs</param>
		/// <param name="accumulator">composite cache rule in which to accumulate cache rules</param>
		/// <returns></returns>
		public static string FormattedTopic(AbsoluteTopicName topic, OutputFormat format, bool showDiffs, Federation aFederation, LinkMaker lm, CompositeCacheRule accumulator)
		{ 
		
			// Show the current topic (including diffs if there is a previous version)
			AbsoluteTopicName previousVersion = null;
			ContentBase relativeToBase = aFederation.ContentBaseForNamespace(topic.Namespace);

			if (showDiffs)
				previousVersion = relativeToBase.VersionPreviousTo(topic.LocalName);

			return FormattedTopicWithSpecificDiffs(topic, format, previousVersion, aFederation, lm, accumulator);
		}
コード例 #3
0
ファイル: Formatter.cs プロジェクト: nuxleus/flexwiki
		/// <summary>
		/// Answer the formatted text for a given topic, formatted using a given OutputFormat and possibly showing diffs
		/// with a specified revision
		/// </summary>
		/// <param name="topic">The topic</param>
		/// <param name="format">What format</param>
		/// <param name="showDiffs">true to show diffs</param>
		/// <param name="accumulator">composite cache rule in which to accumulate cache rules (ignored for diffs)</param>
		/// <returns></returns>
		public static string FormattedTopicWithSpecificDiffs(AbsoluteTopicName topic, OutputFormat format, AbsoluteTopicName diffWithThisVersion, Federation aFederation, LinkMaker lm, CompositeCacheRule accumulator)
		{ 

			// Setup a special link maker that knows what to make the edit links return to 
			LinkMaker linker = lm.Clone();
			linker.ReturnToTopicForEditLinks = topic;
			ContentBase relativeToBase = aFederation.ContentBaseForNamespace(topic.Namespace);

			if (accumulator != null)
				accumulator.Add(relativeToBase.CacheRuleForAllPossibleInstancesOfTopic(topic));
			WikiOutput output = WikiOutput.ForFormat(format, null);
			if (diffWithThisVersion != null)
			{
				ArrayList styledLines = new ArrayList();
				IList leftLines;
				IList rightLines;
				using (TextReader srLeft = relativeToBase.TextReaderForTopic(topic.LocalName))
				{
					leftLines = MergeBehaviorLines(srLeft.ReadToEnd().Replace("\r", "").Split('\n'));
				}
				using (TextReader srRight = relativeToBase.TextReaderForTopic(diffWithThisVersion.LocalName))
				{
					rightLines = MergeBehaviorLines(srRight.ReadToEnd().Replace("\r", "").Split('\n'));
				}
				IEnumerable diffs = Diff.Compare(leftLines, rightLines);
				foreach (LineData ld in diffs)
				{ 
					LineStyle style = LineStyle.Unchanged;
					switch (ld.Type)
					{
						case LineType.Common:
							style = LineStyle.Unchanged;
							break;

						case LineType.LeftOnly:
							style = LineStyle.Add;
							break;

						case LineType.RightOnly:
							style = LineStyle.Delete;
							break;
					}
					styledLines.Add(new StyledLine(ld.Text, style));
				}
				Format(topic, styledLines, output, relativeToBase, linker, relativeToBase.ExternalWikiHash(), 0, accumulator);
			}
			else
			{
				using (TextReader sr = relativeToBase.TextReaderForTopic(topic.LocalName))
				{
					Format(topic, sr.ReadToEnd(), output, relativeToBase, linker, relativeToBase.ExternalWikiHash(), 0, accumulator);
				}
			}

			return output.ToString();
		}
コード例 #4
0
ファイル: Formatter.cs プロジェクト: nuxleus/flexwiki
		/// <summary>
		/// Answer the formatted text for a given topic, formatted using a given OutputFormat and possibly showing diffs with the previous revision
		/// </summary>
		/// <param name="topic">The topic</param>
		/// <param name="format">What format</param>
		/// <param name="showDiffs">true to show diffs</param>
		/// <param name="accumulator">composite cache rule in which to accumulate cache rules</param>
		/// <returns></returns>
		public static string FormattedTopic(AbsoluteTopicName topic, OutputFormat format, AbsoluteTopicName previousVersion, Federation aFederation, LinkMaker lm, CompositeCacheRule accumulator)
		{ 
			ContentBase relativeToBase = aFederation.ContentBaseForNamespace(topic.Namespace);
			return FormattedTopicWithSpecificDiffs(topic, format, previousVersion, aFederation, lm, accumulator);
		}
コード例 #5
0
		/// <summary>
		/// Called when a provider definition is changed.  Should make sure the right changes happen in the federation
		/// to reflect the updated provider definition (e.g., removing/adding/updating namespace registrations).
		/// </summary>
		/// <param name="aFed"></param>
		public void UpdateNamespaces(Federation aFed)
		{
			// just kill the old one and reload a new one
			aFed.UnregisterNamespace(aFed.ContentBaseForNamespace(Namespace));
			LoadNamespaces(aFed);
		}
コード例 #6
0
		/// <summary>
		/// Validate the parameters for creating the Namespace.
		/// </summary>
		/// <param name="param">Parameters name</param>
		/// <param name="val">Parameter value to validate.</param>
		/// <returns>returns null to indicate success otherwise returns 
		/// the error message to be displayed.</returns>
		public string ValidateParameter(Federation aFed, string param, string val, bool isCreate)
		{
			if (param == ConfigurationParameterNames.Namespace)
			{
				// Would need to be consistent with the namespace 
				// names for the FileSystemNameSpaceProvider
				if (val == "" || val == null)
					return "Namespace can not be blank";
				if (isCreate && aFed.ContentBaseForNamespace(val) != null)
					return "Namespace already exists";
			}
			else if (param == ConfigurationParameterNames.ConnectionString)
			{
				if (val == "")
					return "ConnectionString can not be null or blank";
			}
			return null;
		}