public static IEnumerable <TemplateLicense> GetLicenses(TemplateValidator.ValidationTemplateInfo ti) { var licenses = GetValueFromTemplateTag(ti, "wts.licenses"); if (string.IsNullOrWhiteSpace(licenses)) { return(Enumerable.Empty <TemplateLicense>()); } var result = new List <TemplateLicense>(); var licensesMatches = Regex.Matches(licenses, @"\[(?<text>.*?)\]\((?<url>.*?)\)\|?"); for (int i = 0; i < licensesMatches.Count; i++) { var m = licensesMatches[i]; if (m.Success) { result.Add(new TemplateLicense { Text = m.Groups["text"].Value, Url = m.Groups["url"].Value }); } } return(result); }
private static string GetValueFromTemplateTag(TemplateValidator.ValidationTemplateInfo templateInfo, string tagName) { if (templateInfo.TemplateTags != null && !string.IsNullOrEmpty(tagName) && templateInfo.TemplateTags.TryGetValue(tagName, out string tagValue)) { return(tagValue); } return(null); }