本文整理汇总了C#中FlexWiki.LinkMaker类的典型用法代码示例。如果您正苦于以下问题:C# LinkMaker类的具体用法?C# LinkMaker怎么用?C# LinkMaker使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
LinkMaker类属于FlexWiki命名空间,在下文中一共展示了LinkMaker类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Init
[SetUp] public void Init()
{
// Dump the contents of the embedded resources to a file so we can read them
// in during the tests.
meerkatRssPath = Path.GetFullPath("meerkat.rss.xml");
testRssXmlPath = Path.GetFullPath("rsstest.xml");
testRssXslPath = Path.GetFullPath("rsstest.xsl");
Assembly a = Assembly.GetExecutingAssembly();
WriteResourceToFile(a, "FlexWiki.UnitTests.TestContent.meerkat.rss.xml", meerkatRssPath);
WriteResourceToFile(a, "FlexWiki.UnitTests.TestContent.rsstest.xml", testRssXmlPath);
WriteResourceToFile(a, "FlexWiki.UnitTests.TestContent.rsstest.xsl", testRssXslPath);
_lm = new LinkMaker(_base);
TheFederation = new Federation(OutputFormat.HTML, _lm);
TheFederation.WikiTalkVersion = 1;
_cb = CreateStore("FlexWiki");
_cb.Title = "Friendly Title";
WriteTestTopicAndNewVersion(_cb, "HomePage", "Home is where the heart is", user);
WriteTestTopicAndNewVersion(_cb, "BigPolicy", "This is ", user);
WriteTestTopicAndNewVersion(_cb, "BigDog", "This is ", user);
WriteTestTopicAndNewVersion(_cb, "BigAddress", "This is ", user);
WriteTestTopicAndNewVersion(_cb, "BigBox", "This is ", user);
WriteTestTopicAndNewVersion(_cb, "IncludeOne", "inc1", user);
WriteTestTopicAndNewVersion(_cb, "IncludeTwo", "!inc2", user);
WriteTestTopicAndNewVersion(_cb, "IncludeThree", "!!inc3", user);
WriteTestTopicAndNewVersion(_cb, "IncludeFour", "!inc4", user);
WriteTestTopicAndNewVersion(_cb, "IncludeNest", @" {{IncludeNest1}}
{{IncludeNest2}}", user);
WriteTestTopicAndNewVersion(_cb, "TopicWithColor", "Color: Yellow", user);
WriteTestTopicAndNewVersion(_cb, "IncludeNest1", "!hey there", user);
WriteTestTopicAndNewVersion(_cb, "IncludeNest2", "!black dog", user);
WriteTestTopicAndNewVersion(_cb, "IncludeNestURI", @"wiki://IncludeNest1 wiki://IncludeNest2 ", user);
WriteTestTopicAndNewVersion(_cb, "ResourceReference", @"URI: http://www.google.com/$$$", user);
WriteTestTopicAndNewVersion(_cb, "FlexWiki", "flex ", user);
WriteTestTopicAndNewVersion(_cb, "InlineTestTopic", @"aaa @@""foo""@@ zzz", user);
WriteTestTopicAndNewVersion(_cb, "OneMinuteWiki", "one ", user);
WriteTestTopicAndNewVersion(_cb, "TestIncludesBehaviors", "@@[email protected]@ somthing @@[email protected]@ then @@[email protected]@", user);
WriteTestTopicAndNewVersion(_cb, "_Underscore", "Underscore", user);
WriteTestTopicAndNewVersion(_cb, "TopicWithBehaviorProperties", @"
Face: {""hello"".Length}
one
FaceWithArg: {arg | arg.Length }
FaceSpanningLines:{ arg |
arg.Length
}
", user);
WriteTestTopicAndNewVersion(_cb, "TestTopicWithBehaviorProperties", @"
[email protected]@[email protected]@
[email protected]@topics.TopicWithBehaviorProperties.FaceWithArg(""superb"")@@
[email protected]@topics.TopicWithBehaviorProperties.FaceSpanningLines(""parsing is wonderful"")@@
", user);
_externals = new Hashtable();
}
示例2: Main
static void Main(string[] args)
{
if (args.Length < 1)
{
Usage();
return;
}
string fsPath = args[0];
string topic = null;
if (args.Length > 1)
topic = args[1];
LinkMaker lm = new LinkMaker("http://dummy");
Federation fed = new Federation(fsPath, OutputFormat.HTML, lm);
fed.EnableCaching();
if (topic != null)
Print(fed, new AbsoluteTopicName(topic));
else
{
int max = 10;
foreach (AbsoluteTopicName top in fed.DefaultContentBase.AllTopics(false))
{
Print(fed, top);
if (max-- <= 0)
break;
}
}
}
示例3: Main
static void Main(string[] args)
{
if (args.Length < 1)
{
Usage();
return;
}
string fsPath = args[0];
string topic = null;
if (args.Length > 1)
topic = args[1];
LinkMaker lm = new LinkMaker("http://dummy");
PrintTopicApplication application = new PrintTopicApplication(fsPath, lm);
Federation fed = new Federation(application);
if (topic != null)
Print(fed, new TopicName(topic));
else
{
int max = 10;
foreach (TopicName top in fed.DefaultNamespaceManager.AllTopics(ImportPolicy.DoNotIncludeImports))
{
Print(fed, top);
if (max-- <= 0)
break;
}
}
}
示例4: SetUp
public void SetUp()
{
_lm = new LinkMaker(_bh);
MockWikiApplication application = new MockWikiApplication(null, _lm, OutputFormat.HTML,
new MockTimeProvider(TimeSpan.FromSeconds(1)));
Federation = new Federation(application);
}
示例5: MockWikiApplication
public MockWikiApplication(LinkMaker linkMaker,
OutputFormat outputFormat)
{
_linkMaker = linkMaker;
_ouputFormat = outputFormat;
LoadConfiguration();
}
示例6: NewsletterManager
public NewsletterManager(Federation aFed, LinkMaker lm, IDeliveryBoy boy, string newslettersFrom, string headInsert)
{
_LinkMaker = lm;
_NewslettersFrom = newslettersFrom;
_Federation = aFed;
_DeliveryBoy = boy;
_HeadInsert = headInsert;
}
示例7: FormattedTopic
/// <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);
}
示例8: FormattedString
/// <summary>
/// Format a string of wiki content in a given OutputFormat with references all being relative to a given namespace
/// </summary>
/// <param name="input">The input wiki text</param>
/// <param name="format">The desired output format</param>
/// <param name="relativeToContentBase">References will be relative to this namespace</param>
/// <param name="lm">Link maker (unless no relativeTo content base is provide)</param>
/// <param name="accumulator">composite cache rule in which to accumulate cache rules</param>
/// <returns></returns>
public static string FormattedString(string input, OutputFormat format, ContentBase relativeToContentBase, LinkMaker lm, CompositeCacheRule accumulator)
{
// TODO -- some of the cases in which this call happens actually *are* nested, even though the false arg
// below says that they aren't. This causes scripts to be emitted multiple times -- should clean up.
WikiOutput output = WikiOutput.ForFormat(format, null);
Hashtable ew;
if (relativeToContentBase != null)
ew = relativeToContentBase.ExternalWikiHash();
else
ew = new Hashtable();
Format(null, input, output, relativeToContentBase, lm, ew, 0, accumulator);
return output.ToString();
}
示例9: Format
/// <summary>
/// Format a given input string to the given output
/// </summary>
/// <param name="source">Input wiki content as a list of StyledLines</param>
/// <param name="output">Output object to which output is sent</param>
/// <param name="contentBase">The ContentBase that contains the wiki string text</param>
/// <param name="maker">A link maker </param>
/// <param name="external">External wiki map</param>
/// <param name="headingLevelBase">Relative heading level</param>
/// <param name="accumulator">composite cache rule in which to accumulate cache rules</param>
///
static public void Format(AbsoluteTopicName topic, IList source, WikiOutput output, ContentBase contentBase, LinkMaker maker, Hashtable external, int headingLevelBase, CompositeCacheRule accumulator)
{
Formatter f = new Formatter(topic, source, output, contentBase, maker, external, headingLevelBase, accumulator);
f.Format();
}
示例10: WriteNewTopic
private void WriteNewTopic(AbsoluteTopicName theTopic, string postedTopicText, string visitorIdentityString, string version)
{
_linkMaker = new LinkMaker(RootUrl(Context.Request));
AbsoluteTopicName newVersionName = new AbsoluteTopicName(theTopic.Name, theTopic.Namespace);
newVersionName.Version = TopicName.NewVersionStringForUser(visitorIdentityString);
TheFederation.ContentBaseForTopic(newVersionName).WriteTopicAndNewVersion(newVersionName.LocalName, postedTopicText);
}
示例11: FormattedTopicWithSpecificDiffs
/// <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(QualifiedTopicRevision topic, OutputFormat format, QualifiedTopicRevision diffWithThisVersion, Federation aFederation, LinkMaker lm)
{
// Setup a special link maker that knows what to make the edit links return to
LinkMaker linker = lm.Clone();
linker.ReturnToTopicForEditLinks = topic;
NamespaceManager relativeToBase = aFederation.NamespaceManagerForNamespace(topic.Namespace);
WikiOutput output = WikiOutput.ForFormat(format, null);
if (diffWithThisVersion != null)
{
ArrayList styledLines = new ArrayList();
IList leftLines;
IList rightLines;
using (TextReader srLeft = relativeToBase.TextReaderForTopic(topic.AsUnqualifiedTopicRevision()))
{
leftLines = MergeBehaviorLines(srLeft.ReadToEnd().Replace("\r", "").Split('\n'));
}
using (TextReader srRight = relativeToBase.TextReaderForTopic(diffWithThisVersion.AsUnqualifiedTopicRevision()))
{
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.ExternalReferences, 0);
}
else
{
using (TextReader sr = relativeToBase.TextReaderForTopic(topic.AsUnqualifiedTopicRevision()))
{
Format(topic, sr.ReadToEnd(), output, relativeToBase, linker, relativeToBase.ExternalReferences, 0);
}
}
return output.ToString();
}
示例12: FormattedString
/// <summary>
/// Format a string of wiki content in a given OutputFormat with references all being relative to a given namespace
/// </summary>
/// <param name="topic">Topic context</param>
/// <param name="input">The input wiki text</param>
/// <param name="format">The desired output format</param>
/// <param name="relativeToContentStore">References will be relative to this namespace</param>
/// <param name="lm">Link maker (unless no relativeTo content base is provide)</param>
/// <param name="accumulator">composite cache rule in which to accumulate cache rules</param>
/// <returns></returns>
public static string FormattedString(QualifiedTopicRevision topic, string input, OutputFormat format, NamespaceManager relativeToContentStore, LinkMaker lm)
{
// TODO -- some of the cases in which this call happens actually *are* nested, even though the false arg
// below says that they aren't. This causes scripts to be emitted multiple times -- should clean up.
WikiOutput output = WikiOutput.ForFormat(format, null);
ExternalReferencesMap ew;
if (relativeToContentStore != null)
{
ew = relativeToContentStore.ExternalReferences;
}
else
{
ew = new ExternalReferencesMap();
}
Format(topic, input, output, relativeToContentStore, lm, ew, 0);
return output.ToString();
}
示例13: Formatter
/// <summary>
/// Create a new formatter for an input list of StyledLines
/// </summary>
/// <param name="source">Input wiki content as a list of StyledLines</param>
/// <param name="output">Output object to which output is sent</param>
/// <param name="namespaceManager">The ContentProviderChain that contains the wiki string text</param>
/// <param name="maker">A link maker </param>
/// <param name="external">External wiki map</param>
/// <param name="headingLevelBase">Relative heading level</param>
/// <param name="accumulator">composite cache rule in which to accumulate cache rules</param>
///
Formatter(QualifiedTopicRevision topic, IList source, WikiOutput output, NamespaceManager namespaceManager,
LinkMaker maker, ExternalReferencesMap external, int headingLevelBase)
{
_topic = topic;
_source = source;
_output = output;
_linkMaker = maker;
NamespaceManager = namespaceManager;
_externalWikiMap = external;
_headingLevelBase = headingLevelBase;
}
示例14: FormattedTopicWithSpecificDiffs
/// <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();
}
示例15: Formatter
/// <summary>
/// Create a new formatter for an input list of StyledLines
/// </summary>
/// <param name="source">Input wiki content as a list of StyledLines</param>
/// <param name="output">Output object to which output is sent</param>
/// <param name="contentBase">The ContentBase that contains the wiki string text</param>
/// <param name="maker">A link maker </param>
/// <param name="external">External wiki map</param>
/// <param name="headingLevelBase">Relative heading level</param>
/// <param name="accumulator">composite cache rule in which to accumulate cache rules</param>
///
Formatter(AbsoluteTopicName topic, IList source, WikiOutput output, ContentBase contentBase, LinkMaker maker, Hashtable external, int headingLevelBase, CompositeCacheRule accumulator)
{
_Topic = topic;
_Source = source;
_Output = output;
_LinkMaker = maker;
ContentBase = contentBase;
_ExternalWikiMap = external;
_HeadingLevelBase = headingLevelBase;
_CacheRuleAccumulator = accumulator;
}