本文整理汇总了C#中Title.AsTalk方法的典型用法代码示例。如果您正苦于以下问题:C# Title.AsTalk方法的具体用法?C# Title.AsTalk怎么用?C# Title.AsTalk使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Title
的用法示例。
在下文中一共展示了Title.AsTalk方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MovePage
public static IList<PageBE> MovePage(PageBE sourcePage, Title title) {
//Get a list of pages (including child pages)
//Can all pages be moved (Authorization/Namespace check/Homepage)
//Does page exist at proposed title(s)? (including all child titles)
// IsRedirect: Delete it!
// Not a redirect: Exit with error.
//Update page (title/ns/parent_id) and children (title/ns)
//Update Olds, Archive (title + ns)
//Write to RC
//Update links
IList<PageBE> ret = null;
// page path did not change but display name is changed: just change the displayname
if(sourcePage.Title == title && !StringUtil.EqualsInvariant(title.DisplayName, sourcePage.Title.DisplayName)) {
// Path isn't being modified but only the displayname: Change the displayname and return.
sourcePage = SetPageDisplayTitle(sourcePage, title.DisplayName);
List<PageBE> r = new List<PageBE>();
r.Add(sourcePage);
return r;
}
//Validation of move based on source page + destination title/ns
PageBL.ValidatePageMoveForRootNode(sourcePage, title);
//Retrieve all child pages of source page and associated talk pages, including source page
List<PageBE> pagesToMoveList = new List<PageBE>();
List<PageBE> childRedirectsToRecreate = new List<PageBE>();
//Retrieve all descendant pages including redirects. Separate out the redirects to be deleted and readded later.
foreach(PageBE p in GetDescendants(sourcePage, false)) {
if(p.IsRedirect) {
childRedirectsToRecreate.Add(p);
} else {
pagesToMoveList.Add(p);
}
}
// Ensure that redirect text is populated since the page is deleted before it would be lazy loaded
foreach(PageBE redirect in childRedirectsToRecreate) {
redirect.GetText(DbUtils.CurrentSession);
}
pagesToMoveList.AddRange(GetTalkPages(pagesToMoveList));
PageBE[] pagesToMove = pagesToMoveList.ToArray();
//Determine new page titles for every moved page
Dictionary<ulong, Title> newTitlesByPageId = BuildNewTitlesForMovedPages(sourcePage.Title, pagesToMove, title);
//Will throw an unauthorized exception
PermissionsBL.FilterDisallowed(DekiContext.Current.User, pagesToMove, true, Permissions.UPDATE);
Title[] newTitles = new Title[newTitlesByPageId.Count];
newTitlesByPageId.Values.CopyTo(newTitles, 0);
TransactionBE newTrans = new TransactionBE();
newTrans.UserId = DekiContext.Current.User.ID;
newTrans.PageId = sourcePage.ID;
newTrans.Title = sourcePage.Title;
newTrans.Type = RC.MOVE;
newTrans.TimeStamp = DateTime.UtcNow;
uint transId = DbUtils.CurrentSession.Transactions_Insert(newTrans);
try {
//Target titles can only be redirects or talk pages (which are deleted before the move)
EnsureTargetTitlesAvailableForMove(newTitles);
//Retrieve or create the new parent page of the root node
PageBE newParentPage = EnsureParent(sourcePage.IsRedirect, title);
//Ensure user has CREATE access on the proposed new parent page
PermissionsBL.CheckUserAllowed(DekiContext.Current.User, newParentPage, Permissions.CREATE);
//Perform update on titles in pages and olds. parent id in pages is updated as well.
DbUtils.CurrentSession.Pages_UpdateTitlesForMove(sourcePage.Title, newParentPage.Title.IsRoot ? 0 : newParentPage.ID, title, DreamContext.Current.StartTime);
DbUtils.CurrentSession.Pages_UpdateTitlesForMove(sourcePage.Title.AsTalk(), 0, title.AsTalk(), DreamContext.Current.StartTime);
// Perform displayname update to page after the location change
if(!StringUtil.EqualsInvariant(title.DisplayName, sourcePage.Title.DisplayName)) {
PageBE updatedRootPage = GetPageById(sourcePage.ID);
if(updatedRootPage != null) {
SetPageDisplayTitle(updatedRootPage, title.DisplayName);
}
}
// Build return value from current state in the db
List<PageBE> movedPages =
DbUtils.CurrentSession.Pages_GetByIds(from p in pagesToMove select p.ID).ToList();
ret = new List<PageBE>(from p in movedPages select p.Copy());
// All pages have now been moved. Process recent changes, redirects, and events on another thread
Async.Fork(() => {
// Create redirects from previous titles to new titles
try {
MovePageProcessRedirects(pagesToMoveList, newTitlesByPageId, childRedirectsToRecreate);
//.........这里部分代码省略.........
示例2: BuildNewTitlesForMovedPage
private static Title BuildNewTitlesForMovedPage(Title rootTitle, Title currentTitle, Title newTitleForRootPage) {
string titleRelativeToRootNode = currentTitle.AsPrefixedDbPath().Substring((currentTitle.IsTalk ? rootTitle.AsTalk() : rootTitle).AsPrefixedDbPath().Length);
return Title.FromPrefixedDbPath((currentTitle.IsTalk ? newTitleForRootPage.AsTalk() : newTitleForRootPage).AsPrefixedDbPath() + titleRelativeToRootNode, currentTitle.DisplayName);
}
示例3: BuildNewTitlesForMovedPages
private static Dictionary<ulong, Title> BuildNewTitlesForMovedPages(Title rootTitle, PageBE[] pagesToMove, Title newTitleForRootPage) {
Dictionary<ulong, Title> newTitlesByPageId = new Dictionary<ulong, Title>();
foreach(PageBE pageToMove in pagesToMove) {
string titleRelativeToRootNode = pageToMove.Title.AsPrefixedDbPath().Substring((pageToMove.Title.IsTalk ? rootTitle.AsTalk() : rootTitle).AsPrefixedDbPath().Length);
newTitlesByPageId[pageToMove.ID] = Title.FromPrefixedDbPath((pageToMove.Title.IsTalk ? newTitleForRootPage.AsTalk() : newTitleForRootPage).AsPrefixedDbPath() + titleRelativeToRootNode, pageToMove.Title.DisplayName);
}
return newTitlesByPageId;
}