-
Notifications
You must be signed in to change notification settings - Fork 4
/
TextUtility.Framework.cs
46 lines (38 loc) · 1.23 KB
/
TextUtility.Framework.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
namespace Menees
{
#region Using Directives
using System;
using System.Collections.Generic;
using System.Data.Entity.Design.PluralizationServices;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
#endregion
public static partial class TextUtility
{
#region Public Methods
/// <summary>
/// Gets the plural form of the specified word.
/// </summary>
/// <param name="word">The word to make plural.</param>
public static string MakePlural(string word)
{
PluralizationService service = CreatePluralizationService();
string plural = service.Pluralize(word);
string result = PreserveCase(word, plural);
return result;
}
#endregion
#region Private Methods
private static PluralizationService CreatePluralizationService()
{
// Entity Framework's pluralization service only works with English, which is all we
// care about, but we need to make sure we pass it an English culture.
// http://weblogs.asp.net/kencox/archive/2010/04/10/ef-4-s-pluralizationservice-class-a-singularly-impossible-plurality.aspx
PluralizationService result = PluralizationService.CreateService(CultureInfo.GetCultureInfo("en-US"));
return result;
}
#endregion
}
}