XWiki.Model.Wiki.RemoveXWikiDocument C# (CSharp) Method

RemoveXWikiDocument() public method

Removes a XWikiDocument instance from the wiki structure. This has no effect on the server. It only affects the document list Word works with.
public RemoveXWikiDocument ( XWikiDocument doc ) : void
doc XWikiDocument
return void
        public void RemoveXWikiDocument(XWikiDocument doc)
        {
            foreach (Space space in spaces)
            {
                if (space.name == doc.space)
                {
                    space.documents.Remove(doc);
                }
            }
        }

Usage Example

 /// <summary>
 /// Removes all protected pages from the Word wiki structure.
 /// </summary>
 /// <param name="wiki">The wiki instance.</param>
 /// <param name="wildcards">The list of protected pages wildcards.</param>
 public void HideProtectedPages(Wiki wiki, List<String> wildcards)
 {
     foreach (XWikiDocument doc in wiki.GetAllDocuments())
     {
         foreach (String wildcard in wildcards)
         {
             String docFullName = doc.space + "." + doc.name;
             if (UtilityClass.IsWildcardMatch(wildcard, docFullName, true))
             {
                 wiki.RemoveXWikiDocument(doc);
                 break;
             }
         }
     }
 }