/// <summary>
        /// Searches for a match of ALL searched tags.
        /// </summary>
        /// <param name="searchText">The text we are looking</param>
        /// <param name="packToMatch">The GitHubPackDetail object to search.</param>
        /// <returns>A boolean representing if ALL of the tags searched returned an EXACT match</returns>
        private static bool FoundExactTagMatchForAllTags(string searchText, GitHubPackDetail packToMatch)
        {
            searchText = searchText.ToLower();

            // If there is a comma and multiple tags we must match all of them
            if (searchText.Contains(","))
            {
                foreach (string searchTag in searchText.Split(','))
                {
                    if (!CheckForSingleTagInTagList(searchTag.Trim(), packToMatch.Tags, packToMatch.ManagementPackSystemName))
                    {
                        // If any one tag is matching from the list of tags this isn't a match
                        return(false);
                    }
                }

                Log.WriteTrace(
                    EventType.UIActivity,
                    "Matched all tags on Search String",
                    searchText);

                // Every tag in the search string was found in the Tags on the Pack
                return(true);
            }
            else
            {
                // A Single tag was in the search, perform one check.
                return(CheckForSingleTagInTagList(searchText, packToMatch.Tags, packToMatch.ManagementPackSystemName));
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CommunityPackRowTemplate"/> class
        /// </summary>
        /// <param name="communityPackToDisplay">What pack the UI Element should display.</param>
        public CommunityPackRowTemplate(GitHubPackDetail communityPackToDisplay)
        {
            InitializeComponent();
            this.CommunityPackDisplayedInTemplate = communityPackToDisplay;

            Log.WriteTrace(
                EventType.UIActivity,
                "CommunityPack Display Template Row Created",
                CommunityPackDisplayedInTemplate.ManagementPackSystemName);

            DataContext = this;

            AddDetailsToPanel();
            IndicateCommunityPackInstalledStatus();
        }
 /// <summary>
 /// Checks to see if the search text matches the Display or System name of the pack.
 /// </summary>
 /// <param name="searchText">The text we are looking</param>
 /// <param name="packToMatch">The GitHubPackDetail object to search.</param>
 /// <returns>Boolean representing if the Display or System name was a match for the search.</returns>
 private static bool MatchesDisplayOrSystemName(string searchText, GitHubPackDetail packToMatch)
 {
     searchText = searchText.ToLower();
     return(packToMatch.ManagementPackDisplayName.ToLower().Contains(searchText) ||
            packToMatch.ManagementPackSystemName.ToLower().Contains(searchText));
 }
 /// <summary>
 /// Checks against Tags, Display Name, System Name, and Author.
 /// Searches are not case sensitive.
 /// </summary>
 /// <param name="packToSearch">The <see cref="GitHubPackDetail"/> class instance to search against.</param>
 /// <param name="searchText">The search string to verify.</param>
 /// <returns>Boolean representing if the pack is a match for the search</returns>
 public static bool DoesPackMatchSearchString(GitHubPackDetail packToSearch, string searchText)
 {
     return(MatchesAuthor(searchText, packToSearch) ||
            MatchesDisplayOrSystemName(searchText, packToSearch) ||
            FoundExactTagMatchForAllTags(searchText, packToSearch));
 }
 /// <summary>
 /// Checks to see if the search text matches the Author's name
 /// </summary>
 /// <param name="searchText">The text we are looking</param>
 /// <param name="packToMatch">The GitHubPackDetail object to search.</param>
 /// <returns>Boolean representing if the Author was a match for the search.</returns>
 private static bool MatchesAuthor(string searchText, GitHubPackDetail packToMatch)
 {
     searchText = searchText.ToLower();
     return(packToMatch.Author.ToLower().Contains(searchText));
 }