SolutionExtensions.SuggestionHandler.GetSuggestedExtensions C# (CSharp) Method

GetSuggestedExtensions() private static method

private static GetSuggestedExtensions ( SuggestionFileModel fileModel, string filePath, IEnumerable &hits ) : IEnumerable
fileModel SuggestionFileModel
filePath string
hits IEnumerable
return IEnumerable
        private static IEnumerable<IExtensionModel> GetSuggestedExtensions(SuggestionFileModel fileModel, string filePath, out IEnumerable<string> hits)
        {
            List<IExtensionModel> list = new List<IExtensionModel>();
            List<string> matches = new List<string>();
            string fileType = Path.GetFileName(filePath);

            foreach (string key in fileModel.Extensions.Keys)
                foreach (SuggestionModel model in fileModel.Extensions[key])
                {
                    string match = model?.FileTypes?.FirstOrDefault(ft => fileType.EndsWith(ft, StringComparison.OrdinalIgnoreCase));

                    if (!string.IsNullOrEmpty(match) || model.Category == SuggestionFileModel.GENERAL)
                    {
                        if (!string.IsNullOrEmpty(model.TextMatch) && File.Exists(filePath))
                        {
                            string content = File.ReadAllText(filePath);
                            if (!Regex.IsMatch(content, model.TextMatch))
                                continue;
                        }

                        matches.Add(match);
                        list.Add(model);
                    }
                }

            hits = matches;
            return list;
        }