ToTitleCase() public method

public ToTitleCase ( String str ) : String
str String
return String
コード例 #1
0
ファイル: WebService.cs プロジェクト: usmanasif/pyramid
    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());
    }
コード例 #2
0
ファイル: general.cs プロジェクト: 15831944/JIBE-ERP
    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);
    }
コード例 #3
0
 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()));
 }
コード例 #4
0
    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);
    }
コード例 #5
0
        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()));
        }
コード例 #6
0
        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());
            }
        }
コード例 #7
0
ファイル: StringEx.cs プロジェクト: OranBar/MyRoom
    // 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));
    }
コード例 #8
0
        /// <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);
        }
コード例 #9
0
ファイル: json.aspx.cs プロジェクト: declantyson/mynx
 public string ToTitleCase(string inputString)
 {
     System.Globalization.TextInfo txtInfo = System.Globalization.CultureInfo.CurrentCulture.TextInfo;
     return(txtInfo.ToTitleCase(inputString));
 }
コード例 #10
0
 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));
 }
コード例 #11
0
 public string IlkHarfleriBuyut(string metin)
 {
     System.Globalization.CultureInfo cultureInfo = System.Threading.Thread.CurrentThread.CurrentCulture;
     System.Globalization.TextInfo    textInfo    = cultureInfo.TextInfo;
     return(textInfo.ToTitleCase(metin));
 }
コード例 #12
0
ファイル: MainWindow.xaml.cs プロジェクト: WilStead/IdeaTree
 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);
 }