本文整理汇总了C#中Title.AsUserFriendlyName方法的典型用法代码示例。如果您正苦于以下问题:C# Title.AsUserFriendlyName方法的具体用法?C# Title.AsUserFriendlyName怎么用?C# Title.AsUserFriendlyName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Title
的用法示例。
在下文中一共展示了Title.AsUserFriendlyName方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MWToDWTitle
/// <summary>
/// Converts a MediaWiki title to its MindTouch format
/// </summary>
/// <param name="mwTitle">The title to convert</param>
/// <param name="replaceSeparator">If true, replace ":" with "/"</param>
/// <returns>The converted title</returns>
public Title MWToDWTitle(Site site, Title mwTitle, bool useNewFormat) {
string dbPrefix = null;
string dbPath = mwTitle.AsUnprefixedDbPath();
string displayName = mwTitle.DisplayName;
// create a language heirarchy in the main namespaces
if (CreateLanguageHierarchyForNS(mwTitle.Namespace)) {
dbPrefix = site.DWRootPage + "/";
if (site.MWRootPage == mwTitle.Path && useNewFormat) {
displayName = displayName ?? mwTitle.AsUserFriendlyName();
dbPath = String.Empty;
}
}
// prefix template pages with language to make unique accross langauges
else if (mwTitle.IsTemplate || NS.TEMPLATE_TALK == mwTitle.Namespace || mwTitle.IsSpecial) {
return mwTitle;
}
// if this is a user page that corresponds to a renamed user, rename the page.
else if (mwTitle.IsUser || NS.USER_TALK == mwTitle.Namespace) {
string parentSegment = mwTitle.AsUnprefixedDbSegments()[0];
string newParentSegment;
if (_MWToDWUserNameMap.TryGetValue(parentSegment, out newParentSegment)) {
dbPath = newParentSegment + mwTitle.Path.Substring(newParentSegment.Length - 1);
}
}
if ('/' != MediaWikiConverterContext.Current.MWPageSeparator) {
dbPath = dbPath.Replace("/", "//");
// If desired, replace the page separator with "/"
if (useNewFormat && 0 < MediaWikiConverterContext.Current.MWPageSeparator) {
String[] segments = dbPath.Split(MediaWikiConverterContext.Current.MWPageSeparator);
if (1 < segments.Length) {
StringBuilder result = new StringBuilder();
for (int i = 0; i < segments.Length; i++) {
if ((0 < i && !String.IsNullOrEmpty(segments[i - 1])) &&
!(i == segments.Length - 1 && String.IsNullOrEmpty(segments[i]))) {
result.Append("/");
}
if (String.IsNullOrEmpty(segments[i])) {
result.Append(MediaWikiConverterContext.Current.MWPageSeparator);
} else {
result.Append(segments[i].Trim(new char[] { '_' }));
}
}
dbPath = result.ToString();
}
}
}
dbPath = dbPrefix + dbPath;
return Title.FromDbPath(mwTitle.Namespace, dbPath.Trim('/'), displayName, mwTitle.Filename, mwTitle.Anchor, mwTitle.Query);
}