/// <summary> /// Converts the string to title casing. /// Example: "the quick brown fox jumps over the lazy dog" becomes "The Quick Brown Fox Jumps over the Lazy Dog" /// </summary> /// <param name="value">The string</param> /// <returns></returns> public static string ToTitleCase(this string value) { if (string.IsNullOrEmpty(value)) { return(null); } value = value.Sanitize(true); if (string.IsNullOrEmpty(value)) { return(null); } value = Regex.Replace(value, @"\w+", delegate(Match match) { string v = match.ToString(); bool isBlacklisted = Blacklist.Any(word => word.Equals(v, StringComparison.CurrentCultureIgnoreCase)); return((match.Index != 0 && isBlacklisted) ? v.ToLower().FirstLetterToLower() : v.ToLower().FirstLetterToUpper()); }); // Uitzonderingen // http://taaladvies.net/taal/advies/vraag/543 // d'Ancona, d'Hellewyn MatchCollection matches = Regex.Matches(value, @"[d|D] ?'( *)?[aehiouyAEHIOUY]"); foreach (Match m in matches) { value = value.Replace(m.Value, m.Value.Replace(" ", "").ToUpper().FirstLetterToLower()); } return(value); }
private void EnsureWebFolderIsBlacklisted() { if (!Blacklist.Any(p => p.ToLower().Trim() == WebFolderName.ToLower().Trim())) { Blacklist.Add(WebFolderName); } }
public Kindervriend ExecuteQuery(string name) { if (_blacklist.Any(b => b.Equals(name, StringComparison.CurrentCultureIgnoreCase))) { throw new Exception($"Wie is de {name}?!!11!"); } return(new Kindervriend(name, "Noordpool", int.MaxValue)); }
/// <summary> /// Converts the string to title casing. /// Example: "the quick brown fox jumps over the lazy dog" becomes "The Quick Brown Fox Jumps over the Lazy Dog" /// </summary> /// <param name="s">The string</param> /// <returns></returns> public static string ToTitleCaseLossLess(this string value) { if (string.IsNullOrEmpty(value)) { return(null); } value = value.Sanitize(); if (string.IsNullOrEmpty(value)) { return(null); } return(Regex.Replace(value, @"\w+", delegate(Match match) { string m = match.ToString(); bool isBlacklisted = Blacklist.Any(word => word.Equals(m, StringComparison.CurrentCultureIgnoreCase)); return (match.Index != 0 && isBlacklisted) ? m.FirstLetterToLower() : m.FirstLetterToUpper(); })); }
private bool BlacklistExcludes(string fullName) { return(Blacklist.Any(p => fullName.ToLower().Contains(p.ToLower()))); }