| | | 1 | | // ----------------------------------------------------------------------- |
| | | 2 | | // <copyright file="TitleCasingTransform.cs" company="Stéphane ANDRE"> |
| | | 3 | | // Copyright (c) Stéphane ANDRE. All rights reserved. |
| | | 4 | | // </copyright> |
| | | 5 | | // ----------------------------------------------------------------------- |
| | | 6 | | |
| | | 7 | | using System; |
| | | 8 | | using System.Globalization; |
| | | 9 | | |
| | | 10 | | namespace MyNet.Text.TextCasing; |
| | | 11 | | |
| | | 12 | | /// <summary> |
| | | 13 | | /// Transforms a string to title case, meaning the first letter of each word is capitalized and the rest are lowercase. |
| | | 14 | | /// </summary> |
| | | 15 | | public sealed class TitleCasingTransform : ITextCasingTransform |
| | | 16 | | { |
| | | 17 | | /// <summary> |
| | | 18 | | /// Initializes a new instance of the <see cref="TitleCasingTransform"/> class. |
| | | 19 | | /// </summary> |
| | 6 | 20 | | internal TitleCasingTransform() { } |
| | | 21 | | |
| | | 22 | | /// <summary> |
| | | 23 | | /// Transforms the input string to title case. Each word's first letter is capitalized and the rest are lowercase, e |
| | | 24 | | /// </summary> |
| | | 25 | | /// <param name="input">The string to transform.</param> |
| | | 26 | | /// <param name="culture">The culture to use for the transformation.</param> |
| | | 27 | | /// <returns>The transformed string in title case.</returns> |
| | | 28 | | public string Apply(string input, CultureInfo culture) |
| | | 29 | | { |
| | 63 | 30 | | ArgumentNullException.ThrowIfNull(input); |
| | 63 | 31 | | ArgumentNullException.ThrowIfNull(culture); |
| | | 32 | | |
| | 63 | 33 | | return culture.TextInfo.ToTitleCase(input); |
| | | 34 | | } |
| | | 35 | | } |
| | | 36 | | |