private bool MatchPattern(string text, int index) { if (CaseInsensitive) { if (text.Length - index < Pattern.Length) { return(false); } TextInfo textinfo = _culture.TextInfo; for (int i = 0; i < Pattern.Length; i++) { Debug.Assert(textinfo.ToLower(Pattern[i]) == Pattern[i], "pattern should be converted to lower case in constructor!"); if (textinfo.ToLower(text[index + i]) != Pattern[i]) { return(false); } } return(true); } else { return(0 == string.CompareOrdinal(Pattern, 0, text, index, Pattern.Length)); } }
private static void TextChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs) { var key = dependencyObject as Key; if (key != null) { var value = dependencyPropertyChangedEventArgs.NewValue as string; //Depending on parametrized case, change the value if (value != null) { TextInfo textInfo = Settings.Default.UiLanguage.ToCultureInfo().TextInfo; //If Case is specifically set, use it, otherwise, use setting value switch (key.Case == Case.Settings ? Settings.Default.KeyCase : key.Case) { case Case.Upper: value = textInfo.ToUpper(value); break; case Case.Lower: value = textInfo.ToLower(value); break; case Case.Title: //Must be lowercased first because ToTitleCase consider uppercased string as abreviations value = textInfo.ToTitleCase(textInfo.ToLower(value)); break; } } key.ShiftDownText = value; key.ShiftUpText = value; } }
public IEnumerable <PublicacaoDestino> GetListaPublicacao(string tipo) { var listaPublicacao = Enumerable.Empty <PublicacaoDestino>(); if (tipo == "NACIONAL") { using (var contexto = new BlogContext()) { listaPublicacao = (from p in contexto.Publicacoes where p.idPais == 1 select p).ToArray(); } foreach (var p in listaPublicacao) { p.nomeCidade = textInfo.ToLower(p.nomeCidade); p.nomeEstado = textInfo.ToLower(p.nomeEstado); p.nomeCidade = textInfo.ToTitleCase(p.nomeCidade); p.nomeEstado = textInfo.ToTitleCase(p.nomeEstado); } } else { using (var contexto = new BlogContext()) { listaPublicacao = (from p in contexto.Publicacoes where p.idPais != 1 select p).ToArray(); foreach (var pub in listaPublicacao) { pub.Pais = (from p in contexto.Paises where p.id == pub.idPais select p).FirstOrDefault(); } } foreach (var p in listaPublicacao) { p.nomeCidade = textInfo.ToLower(p.nomeCidade); p.nomeEstado = textInfo.ToLower(p.nomeEstado); p.Pais.nome = textInfo.ToLower(p.Pais.nome); p.nomeCidade = textInfo.ToTitleCase(p.nomeCidade); p.nomeEstado = textInfo.ToTitleCase(p.nomeEstado); p.Pais.nome = textInfo.ToTitleCase(p.Pais.nome); } } return(listaPublicacao); }
private static Func <string, string> GetCaseChange(TextInfo info, string text) { if (info.ToLower(text) == text) { return((txt) => info.ToTitleCase(txt)); } else if (info.ToUpper(text) == text) { return((txt) => info.ToLower(txt)); } else { return((txt) => info.ToUpper(txt)); } }
/// <summary> /// Performs the conversion of "the Cat RAN" into "The Cat Ran" - as quickly as possible. /// </summary> public static string ToPascalSentence(string input) { if (string.IsNullOrEmpty(input)) { return(input); } TextInfo textInfo = CultureInfo.CurrentCulture.TextInfo; int length = input.Length; StringBuilder stringBuilder = new StringBuilder(textInfo.ToLower(input), length); stringBuilder[0] = textInfo.ToUpper(input[0]); int index = input.IndexOf(' ', 0, length - 1); while (index != -1) { int nextCharIndex = index + 1; stringBuilder[nextCharIndex] = textInfo.ToUpper(input[nextCharIndex]); index = input.IndexOf(' ', nextCharIndex, length - index - 2); } return(stringBuilder.ToString()); }
protected override void OnTextChanged(EventArgs e) { int currentpos = base.SelectionStart; TextInfo ti = CultureInfo.CurrentCulture.TextInfo; if (TextTransform == TextDecoration.Capitalize) { base.Text = ti.ToTitleCase(base.Text); } else if (TextTransform == TextDecoration.Lowercase) { base.Text = ti.ToLower(base.Text); } else if (TextTransform == TextDecoration.Uppercase) { base.Text = ti.ToUpper(base.Text); } else { base.Text = base.Text; } base.SelectionStart = currentpos; base.SelectionLength = 0; base.OnTextChanged(e); }
/// <summary> /// ToLower implements the one-to-one Unicode lowercase mapping /// as descriped in ftp://ftp.unicode.org/Public/UNIDATA/UnicodeData.txt. /// The VB spec states that these mappings are used for case-insensitive /// comparison /// </summary> /// <param name="c"></param> /// <returns></returns> public static char ToLower(char c) { // PERF: This is a very hot code path in VB, optimize for Ascii if (IsAscii(c)) { // copied from BCL: Textinfo.ToLowerAsciiInvariant // if ('A' <= c && c <= 'Z') // we will do it with only one branch though since we want this to be fast if (unchecked ((uint)(c - 'A')) <= ('Z' - 'A')) { c = (char)(c | 0x20); } } else if (c == '\u0130') { // Special case Turkish I, see bug 531346 c = 'i'; } else { c = invariantCultureTextInfo.ToLower(c); } return(c); }
public virtual Object GetObject(String name, bool ignoreCase) { // Validate the parameters. if (name == null) { throw new ArgumentNullException("name"); } else if (Reader == null) { throw new InvalidOperationException (_("Invalid_ResourceReaderClosed")); } // Try looking for the resource by exact name. Object value = Table[name]; if (value != null || !ignoreCase) { return(value); } // Create the "ignore case" table if necessary. if (ignoreCaseTable == null) { CreateIgnoreCaseTable(); } // Look for the resource in the "ignore case" table. TextInfo info = CultureInfo.InvariantCulture.TextInfo; return(ignoreCaseTable[info.ToLower(name)]); }
public static string MakeInitSmall(string s, TextInfo textInfo) { #if DEBUG if (s == null) { throw new ArgumentNullException(nameof(s)); } if (textInfo == null) { throw new ArgumentNullException(nameof(textInfo)); } #endif if (s.Length == 0) { return(s); } var actualFirstLetter = s[0]; var expectedFirstLetter = textInfo.ToLower(actualFirstLetter); if (expectedFirstLetter == actualFirstLetter) { return(s); } if (s.Length == 1) { return(expectedFirstLetter.ToString()); } var builder = StringBuilderPool.Get(s, s.Length); builder[0] = expectedFirstLetter; return(StringBuilderPool.GetStringAndReturn(builder)); }
public override void ViewDidLoad() { base.ViewDidLoad(); string menuTitle = _selectedCategory.MENU_CAT_NAME + " Menu"; Title = textInfo.ToTitleCase(textInfo.ToLower(menuTitle)); }
/// public static string toLowerCase(string sString) { CultureInfo cultureInfo = Thread.CurrentThread.CurrentCulture; TextInfo textInfo = cultureInfo.TextInfo; return(textInfo.ToLower(sString)); }
/// <summary> /// Creates a friendly title for the event. /// </summary> /// <param name="type">The event type.</param> /// <param name="ti">The current culture if available.</param> /// <returns>The header for events of that type.</returns> private static string GetProperTitle(EventType type, TextInfo ti = null) { Event.GetUIStrings(type, out string title, out string _); if (ti != null) { title = ti.ToTitleCase(ti.ToLower(title)); } // Green for installed and red for uninstalled / crashed if (type == EventType.ActiveDuringCrash || type == EventType.NotFound) { title = STRINGS.UI.FormatAsAutomationState(title, STRINGS.UI. AutomationState.Standby); } else if (type == EventType.ExpectedActive) { title = DebugNotIncludedStrings.UI.MODEVENTS.DEACTIVATED; } else if (type == EventType.LoadError) { title = DebugNotIncludedStrings.UI.MODEVENTS.NOTLOADED; } else if (type == EventType.ExpectedInactive) { title = DebugNotIncludedStrings.UI.MODEVENTS.ACTIVATED; } else { // Bold the title title = "<b><color=#DEDEFF>" + title + "</color></b>"; } return(title); }
/// <summary> /// Lower case a string. /// </summary> /// <param name="input">The input string to lower case.</param> /// <returns>Returns the lower case version of the string.</returns> public string LowerCase(string input) { CultureInfo cultureInfo = Thread.CurrentThread.CurrentCulture; TextInfo textInfo = cultureInfo.TextInfo; return(textInfo.ToLower(input)); }
public static string ResourceDescription(this Enum value) { string fallback = null; var attributes = value.GetType().GetField(value.ToString()) .GetCustomAttributes(typeof(DescriptionAttribute), false); if (attributes.Any()) { fallback = (attributes.First() as DescriptionAttribute)?.Description; var result = Settings.Resource(fallback); if (!string.IsNullOrWhiteSpace(result)) { return(result); } } if (string.IsNullOrWhiteSpace(fallback)) { fallback = value.ToString(); } TextInfo ti = CultureInfo.CurrentCulture.TextInfo; return(ti.ToTitleCase(ti.ToLower(fallback.Replace("_", " ")))); }
private bool IsMisspelled(string word) { return(_grammarEngine.Spell(word) || _grammarEngine.Spell(_textInfo.ToLower(word)) || _grammarEngine.Spell(_textInfo.ToUpper(word)) || _grammarEngine.Spell(_textInfo.ToTitleCase(word))); }
/// <summary> /// Returns an enumerator that iterates through the collection. /// </summary> /// <returns> /// A <see cref="T:System.Collections.Generic.IEnumerator`1" /> that can be used to iterate through the collection. /// </returns> public IEnumerator <string> GetEnumerator() { Random random = new Random(this.Seed); HashSet <string> usedNames = new HashSet <string>(); Func <IList <string>, string> randomStringFromList = ia => ia[random.Next(ia.Count)]; if (this.MaxItems < 1) { this.MaxItems = int.MaxValue; } for (int i = 0; i < this.MaxItems; i++) { IList <string> list = random.Next(1) == 0 ? this.maleFirstNames : this.femaleFirstNames; string first = randomStringFromList(list); string fullName; if (this.FirstNameOnly) { fullName = TextInfo.ToTitleCase(TextInfo.ToLower(first)); } else { // Add a middle initial 1 in 4 times string initial = (random.Next(4) == 0) ? randomStringFromList(list)[0] + ". " : string.Empty; string last = this.surnames[random.Next(this.surnames.Count)]; fullName = TextInfo.ToTitleCase(TextInfo.ToLower(first + " " + initial + last)); } if (usedNames.Contains(fullName)) { // Name has been used, generate another one continue; } usedNames.Add(fullName); yield return(fullName); } }
private void txtSitio_Leave(object sender, EventArgs e) { CultureInfo cultureInfo = System.Threading.Thread.CurrentThread.CurrentCulture; TextInfo textInfo = cultureInfo.TextInfo; this.txtSitio.Text = textInfo.ToLower(this.txtSitio.Text); this.txtSitio.Text = textInfo.ToTitleCase(this.txtSitio.Text); }
/// <summary> /// Converts a string to lower-case and trims whites space /// </summary> public static string LowerCase(this string value) { if (value.HasNoValue()) { return(value); } return(txt.ToLower(value.Trim())); }
public static String Capitalize(String text) { CultureInfo cultureInfo = Thread.CurrentThread.CurrentCulture; TextInfo textInfo = cultureInfo.TextInfo; text = textInfo.ToLower(text); //evitando que no se consideren acronimos return(textInfo.ToTitleCase(text)); }
private void OnInputValueChanged(string newText) { dd.gameObject.SetActive(true); ClearResults(); newText = textInfo.ToLower(newText); FillResults(GetResults(newText)); }
private static char ToLowerNonAscii(char c) { if (c == '\u0130') { // Special case Turkish I, see bug 531346 return('i'); } return(s_invariantCultureTextInfo.ToLower(c)); }
public static string ToTitleCase(this string text, CultureInfo culture, string separator = " ") { TextInfo textInfo = culture.TextInfo; string lowerText = textInfo.ToLower(text); string[] words = lowerText.Split(new[] { separator }, StringSplitOptions.None); return(String.Join(separator, words.Select(v => textInfo.ToTitleCase(v)))); }
public string FormatProperCase(string str) { CultureInfo cultureInfo = new CultureInfo("vi-VN"); TextInfo textInfo = cultureInfo.TextInfo; str = textInfo.ToLower(str); // Recity multiple white space to 1 white space str = System.Text.RegularExpressions.Regex.Replace(str, @"\s{2,}", " "); //Upcase like Title return(textInfo.ToTitleCase(str)); }
private void crearUsuarioAutomatico(string idRol) { List <string[]> id = new List <string[]>(); int inde; TextInfo ti = CultureInfo.CurrentCulture.TextInfo; string email = "*****@*****.**"; PNegocio.Administrador.Proveedores idprovedor = new PNegocio.Administrador.Proveedores(); string sqlString = "select d.proveedor_idProveedor, d.RFC, d.nombre, d.lifnr from detProveedor d where not exists(select 1 from usuario u where u.proveedor_idProveedor = d.proveedor_idProveedor ) order by nombre asc"; //string sqlString = "select proveedor_idProveedor, RFC, nombre, lifnr from detProveedor where proveedor_idProveedor not in ( select proveedor_idProveedor from usuario ) order by nombre asc"; //string sqlString = "select proveedor_idProveedor, RFC, nombre, lifnr from detProveedor order by nombre asc"; id = idprovedor.consultarProveedoresPorId(sqlString); if (id.Count > 1) { id.RemoveAt(0); for (int i = 0; i < id.Count; i++) { List <string[]> socPorProv = cargarSociedades(id[i][0].Trim()); string[] name = id[i][2].Split(' '); inde = correos.FindIndex(x => x.acreedor.Contains(id[i][3].Trim())); if (inde > 0) { if (String.IsNullOrEmpty(correos[inde].correo)) { email = "*****@*****.**"; } else { email = correos[inde].correo; } } else { email = "*****@*****.**"; } if (name[0].Length < 5) { name[0] = id[i][2].Substring(0, 5).Replace(" ", ""); } string usuario = id[i][3].Trim() + ti.ToTitleCase(ti.ToLower(name[0])); string nombre = id[i][2].Trim(); PNegocio.Administrador.Usuario us = new PNegocio.Administrador.Usuario(); PNegocio.Encript encript = new PNegocio.Encript(); socPorProv.RemoveAt(0); string res = us.insertarUsuario(usuario, nombre, nombre, encript.Encriptar(encript.Encriptar(usuario)), "2010-01-01", "2099-12-31", id[i][0].Trim(), Convert.ToString(1), Convert.ToString(1), email, "Rol Default", socPorProv); if (res.Equals("insertado")) { res = "Se agrego correctamente"; } } } }
/// <summary> /// Gets the description of a specific enum value. /// </summary> public static string Description(this Enum eValue) { var nAttributes = eValue.GetType().GetField(eValue.ToString()).GetCustomAttributes(typeof(DescriptionAttribute), false); if (!nAttributes.Any()) { TextInfo oTI = CultureInfo.CurrentCulture.TextInfo; return(oTI.ToTitleCase(oTI.ToLower(eValue.ToString().Replace("_", " ")))); } return((nAttributes.First() as DescriptionAttribute).Description); }
public static string ToCurrencyInWords(this decimal Number) { String words = ""; try { if (Number == 0) { return(""); } string[] Nums = string.Format("{0:0.00}", Number).Split('.'); int number1 = int.Parse(Nums[0]); int number2 = int.Parse(Nums[1]); words = string.Format("{0}{1}{2}", CurrencyToWordPrefix, number1.ToWords(), CurrencyToWordSuffix); if (number2 > 0) { words = string.Format("{0} AND {1}{2}{3}", words, DecimalToWordPrefix ?? "", number2.ToWords(), DecimalToWordSuffix ?? ""); } if (IsDisplayWithOnlyOnSuffix) { words = string.Format("{0} Only", words); } CultureInfo cultureInfo = Thread.CurrentThread.CurrentCulture; TextInfo textInfo = cultureInfo.TextInfo; if (CurrencyCaseSensitive == 0) { return(textInfo.ToLower(words)); } else if (CurrencyCaseSensitive == 1) { return(textInfo.ToUpper(words)); } else if (CurrencyCaseSensitive == 2) { return(textInfo.ToTitleCase(words.ToLower())); } else { return(words); } } catch (Exception ex) { } return(words); }
private static string StringCaseFormatter(ColumnTypeStringCaseConfiguration stringCase, string value, TextInfo textInfo, bool isFirst) { string formattedText; switch (stringCase) { case ColumnTypeStringCaseConfiguration.Upper: formattedText = textInfo.ToUpper(value); break; case ColumnTypeStringCaseConfiguration.Lower: formattedText = textInfo.ToLower(value); break; case ColumnTypeStringCaseConfiguration.Title: formattedText = textInfo.ToTitleCase(value); break; case ColumnTypeStringCaseConfiguration.Sentence: formattedText = isFirst ? textInfo.ToTitleCase(value) : textInfo.ToLower(value); break; case ColumnTypeStringCaseConfiguration.Camel: formattedText = isFirst ? textInfo.ToLower(value) : textInfo.ToTitleCase(value); break; case ColumnTypeStringCaseConfiguration.Pascal: formattedText = textInfo.ToTitleCase(value); break; case ColumnTypeStringCaseConfiguration.Snake: case ColumnTypeStringCaseConfiguration.Kebab: formattedText = textInfo.ToLower(value); break; default: throw new InvalidOperationException($"String case of type {stringCase} is not valid"); } return(formattedText); }
/// <summary> /// Gets the description of a specific enum value. /// </summary> public static string Description(this Enum eValue) { var nAttributes = eValue.GetType().GetField(eValue.ToString()).GetCustomAttributes(typeof(DescriptionAttribute), false); // If no description is found, best guess is to generate it by replacing underscores with spaces if (!nAttributes.Any()) { TextInfo oTI = CultureInfo.CurrentCulture.TextInfo; return(oTI.ToTitleCase(oTI.ToLower(eValue.ToString().Replace("_", " ")))); } return((nAttributes.First() as DescriptionAttribute).Description); }
private static char ToLowerNonAscii(char c) { if (c == '\u0130') { // Special case Turkish I (LATIN CAPITAL LETTER I WITH DOT ABOVE) // This corrects for the fact that the invariant culture only supports Unicode 1.0 // and therefore does not "know about" this character. return('i'); } return(s_unicodeCultureTextInfo.ToLower(c)); }
public static string ToLower(this string value) { if (value == null || value.Length < 2) { return(value); } CultureInfo cultureInfo = Thread.CurrentThread.CurrentCulture; TextInfo textInfo = cultureInfo.TextInfo; return(textInfo.ToLower(value)); }