public string[] GetLocation(string prefixText, int count) { List <string> lst = new List <string>(); MongoCollection <BasicInfo> objCollection = BaseClass.db.GetCollection <BasicInfo>("c_BasicInfo"); var query = Query.Matches("HomeTown", BsonRegularExpression.Create(new System.Text.RegularExpressions.Regex("^(?i)" + prefixText + ""))); var cursor = objCollection.Find(query); cursor.Limit = 5; System.Globalization.CultureInfo cultureInfo = System.Threading.Thread.CurrentThread.CurrentCulture; System.Globalization.TextInfo txtInfo = cultureInfo.TextInfo; foreach (var item in cursor) { lst.Add(txtInfo.ToTitleCase(item.HomeTown)); } /* var query2 = Query.Matches("HomeTown", BsonRegularExpression.Create(new System.Text.RegularExpressions.Regex("^(?i)" + prefixText + ""))); * * var cursor2 = objCollection.Find(query2); * cursor2.Limit = 5; * foreach (var item in cursor) * { * lst.Add(item.HomeTown); * * }*/ return(lst.Distinct().Take(5).ToArray()); }
public static string GetMixedCase(string myString) { System.Globalization.CultureInfo cultureInfo = System.Threading.Thread.CurrentThread.CurrentCulture; System.Globalization.TextInfo textInfo = cultureInfo.TextInfo; string mixedCaseString = textInfo.ToTitleCase(myString.ToLower()); return(mixedCaseString); }
public static string ToTitleCase(this string mText) { if (mText == null) { return(""); } System.Globalization.CultureInfo cultureInfo = System.Threading.Thread.CurrentThread.CurrentCulture; System.Globalization.TextInfo textInfo = cultureInfo.TextInfo; // TextInfo.ToTitleCase only operates on the string if is all lower case, otherwise it returns the string unchanged. return(textInfo.ToTitleCase(mText.ToLower())); }
public static string ToPascalCase(this String str) { if (str == null) { return(""); } System.Globalization.TextInfo textInfo = System.Globalization.CultureInfo.CurrentUICulture.TextInfo; string result = textInfo.ToTitleCase(str.Trim().Replace("-", " ")).Replace(" ", ""); return(result); }
public static string FormaAcronym(this string s) { if (string.IsNullOrEmpty(s)) { return(s); } System.Globalization.CultureInfo cultureInfo = System.Threading.Thread.CurrentThread.CurrentCulture; System.Globalization.TextInfo textInfo = cultureInfo.TextInfo; return(textInfo.ToTitleCase(s.ToUpper())); }
public bool SendMailAsVisitor(ViewModels.MailViewModel model) { System.Globalization.CultureInfo cultureInfo = System.Threading.Thread.CurrentThread.CurrentCulture; System.Globalization.TextInfo textInfo = cultureInfo.TextInfo; string ad = textInfo.ToTitleCase(model.ad); string soyad = textInfo.ToTitleCase(model.soyad); MailMessage ePosta = new MailMessage(); ePosta.From = new MailAddress("*****@*****.**"); // ePosta.To.Add("*****@*****.**"); // // ePosta.Subject = "Ziyaretçi Mesajı"; // ePosta.Body = ad + " " + soyad + "[" + model.email + "]" + " ziyaretçisinden mesaj;" + Environment.NewLine + Environment.NewLine + model.mesaj; // SmtpClient smtp = new SmtpClient(); // smtp.Credentials = new System.Net.NetworkCredential("*****@*****.**", "159654357456"); smtp.Port = 587; smtp.Host = "smtp.gmail.com"; smtp.EnableSsl = true; object userState = ePosta; try { smtp.SendAsync(ePosta, (object)ePosta); return(true); } catch (SmtpException ex) { throw new SmtpException(ex.ToString()); } }
// IsValidIPAddress #endregion #region ToTitleCase /// <summary> /// Converts the specified string to title case (except for words that are entirely in uppercase, which are considered to be acronyms). /// </summary> /// <param name="mText"></param> /// <returns></returns> public static string ToTitleCase(this string mText) { if (mText.IsNullOrEmpty()) { return(mText); } // get globalization info System.Globalization.CultureInfo cultureInfo = System.Threading.Thread.CurrentThread.CurrentCulture; System.Globalization.TextInfo textInfo = cultureInfo.TextInfo; // convert to title case return(textInfo.ToTitleCase(mText)); }
/// <summary> /// Converts given string to first letter to upper and others to lower. Returns null if value is null. /// </summary> /// <param name="value">The value to be converted.</param> /// <param name="culture">The culture to be used while converting.</param> /// <returns>String</returns> public static string ToTitleCase(this string value, string culture = "tr-TR") { if (value.IsNull()) { return(null); } value = value.Trim(); if (value.Length > 0) { System.Globalization.CultureInfo cultureInfo = new System.Globalization.CultureInfo(culture); System.Globalization.TextInfo textInfo = cultureInfo.TextInfo; value = textInfo.ToLower(value); value = textInfo.ToTitleCase(value); } return(value); }
public string ToTitleCase(string inputString) { System.Globalization.TextInfo txtInfo = System.Globalization.CultureInfo.CurrentCulture.TextInfo; return(txtInfo.ToTitleCase(inputString)); }
public static string ToTitleCase(this string text) { System.Globalization.CultureInfo cultureInfo = System.Threading.Thread.CurrentThread.CurrentCulture; System.Globalization.TextInfo textInfo = cultureInfo.TextInfo; return(textInfo.ToTitleCase(text)); }
public string IlkHarfleriBuyut(string metin) { System.Globalization.CultureInfo cultureInfo = System.Threading.Thread.CurrentThread.CurrentCulture; System.Globalization.TextInfo textInfo = cultureInfo.TextInfo; return(textInfo.ToTitleCase(metin)); }
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); }