/// <summary> /// Based on a <see cref="GitHubPackDetail"/> array, this method builds out the displayed list of packs. /// </summary> /// <param name="packsToDisplay">An optional array of <see cref="GitHubPackDetail"/>. Providing NULL will fetch the list from GitHub</param> private void PopulateCommunityManagementPackListFromGitHub(GitHubPackDetail[] packsToDisplay) { if (packsToDisplay == null || communityManagementPackIndex == null) { communityManagementPackIndex = new Models.GitHubRepository(); Task.Run(() => communityManagementPackIndex.PopulateDataFromRepository("DiscoverPacks")).Wait(); packsToDisplay = communityManagementPackIndex.ManagementPacks.Values.ToArray(); } // Empty the list prior to re-populating CommunityPackList.Items.Clear(); foreach (GitHubPackDetail communityPack in packsToDisplay.OrderBy(mp => mp.ManagementPackDisplayName)) { CommunityPackRowTemplate packListTemplateDisplay = new CommunityPackRowTemplate(communityPack); // Before Adding the Tags, we pass the Tag Selection Event handles through packListTemplateDisplay.RowFilterTagSelected += FilterTagSelectedByUser; packListTemplateDisplay.RowFilterTagRemoved += FilterTagRemovedByUser; packListTemplateDisplay.RowAuthorSelected += FilterAuthorSelected; // Now populate the tags, they will connect to the above handles. packListTemplateDisplay.PopulateTagsOnRow(); this.ManagementPackSearchChanged += packListTemplateDisplay.SearchUpdated; CommunityPackList.Items.Add(packListTemplateDisplay); } }
/// <summary> /// Confirm that the <see cref="communityManagementPackIndex"/> variable is properly populated. /// If the value is null the data will be re-fetched from GitHub /// </summary> private void CheckAndFillGitHubIndex() { if (communityManagementPackIndex != null) { // We've got data and we can proceeded return; } else { // Loop through our GitHub packs an populate a Installed Pack (if applicable) communityManagementPackIndex = new Models.GitHubRepository(); Task.Run(() => communityManagementPackIndex.PopulateDataFromRepository("InstalledPacks")).Wait(); var managementPackInventory = ManagementGroup.ManagementPacks.GetManagementPacks(); foreach (GitHubPackDetail communityPack in communityManagementPackIndex.ManagementPacks.Values) { communityPack.InstalledManagementPack = managementPackInventory.Where(mp => mp.Name == communityPack.ManagementPackSystemName).FirstOrDefault(); if (communityPack.InstalledManagementPack != null) { LogManager.Log.WriteTrace( LogManager.EventType.ExternalDependency, "Found Matching Management Pack", communityPack.ManagementPackSystemName); } } } }