ScrewTurn.Wiki.PagesStorageProvider.GetPages C# (CSharp) Method

GetPages() public method

Gets all the Pages in a namespace.
public GetPages ( NamespaceInfo nspace ) : System.PageInfo[]
nspace NamespaceInfo The namespace (null for the root).
return System.PageInfo[]
        public PageInfo[] GetPages(NamespaceInfo nspace)
        {
            lock(this) {
                PageInfo[] allPages = GetAllPages();

                // Preallocate assuming that there are 2 namespaces and that they are evenly distributed across them:
                // pages can be as much as many thousands, so preallocating a smaller number can cause a performance loss
                List<PageInfo> selectedPages = new List<PageInfo>(allPages.Length / 2);

                // Select pages that have the same namespace as the requested one,
                // either null-null or same name
                foreach(PageInfo page in allPages) {
                    string pageNamespace = NameTools.GetNamespace(page.FullName);
                    if(nspace == null && pageNamespace == null) selectedPages.Add(page);
                    if(nspace != null && pageNamespace != null && StringComparer.OrdinalIgnoreCase.Compare(nspace.Name, pageNamespace) == 0) selectedPages.Add(page);
                }

                return selectedPages.ToArray();
            }
        }
PagesStorageProvider