ArcGISPortalViewer.Model.PortalService.GetPortalItemsInternal C# (CSharp) Method

GetPortalItemsInternal() private method

private GetPortalItemsInternal ( ItemsRequestedType itemsRequestedType = ItemsRequestedType.Default, SearchParameters searchParameters = null ) : Task>
itemsRequestedType ItemsRequestedType
searchParameters SearchParameters
return Task>
        private async Task<IList<ArcGISPortalItem>> GetPortalItemsInternal(
            ItemsRequestedType itemsRequestedType = ItemsRequestedType.Default, 
            SearchParameters searchParameters = null)
        {
            IList<ArcGISPortalItem> results = new List<ArcGISPortalItem>();
            if (CurrentPortalService.Portal == null || CurrentPortalService.Portal.ArcGISPortalInfo == null)
                return results;

            SearchResultInfo<ArcGISPortalItem> items = null;
            try
            {
                switch (itemsRequestedType)
                {
                    case ItemsRequestedType.Default:
                        if (searchParameters != null)
                            items = await GetSearchResults(searchParameters);
                        break;
                    case ItemsRequestedType.Featured:
                        items = await CurrentPortalService.Portal.ArcGISPortalInfo.SearchFeaturedItemsAsync(searchParameters);
                        break;
                    case ItemsRequestedType.Basemaps:
                        items = await CurrentPortalService.Portal.ArcGISPortalInfo.SearchBasemapGalleryAsync(searchParameters);
                        break;
                }                
                if (items != null)
                {
                    foreach (ArcGISPortalItem item in items.Results)
                        results.Add(item);
                }
                return results;
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }            
        }