PluralizationServiceUtil.cs source code in C# .NET

Source code for the .NET framework in C#

                        

Code:

/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / DataEntityDesign / Design / System / Data / Entity / Design / PluralizationService / PluralizationServiceUtil.cs / 1305376 / PluralizationServiceUtil.cs

                            //---------------------------------------------------------------------- 
// 
//      Copyright (c) Microsoft Corporation.  All rights reserved.
// 
// 
// @owner       [....]
// @backupOwner [....] 
//--------------------------------------------------------------------- 
using System;
using System.Collections.Generic; 
using System.Text;
using System.Linq;
using System.Globalization;
 
namespace System.Data.Entity.Design.PluralizationServices
{ 
    internal static class PluralizationServiceUtil 
    {
        internal static bool DoesWordContainSuffix(string word, IEnumerable suffixes, CultureInfo culture) 
        {
            if (suffixes.Any(s => word.EndsWith(s, true, culture)))
            {
                return true; 
            }
            else 
            { 
                return false;
            } 
        }

        internal static bool TryGetMatchedSuffixForWord(string word, IEnumerable suffixes, CultureInfo culture, out string matchedSuffix)
        { 
            matchedSuffix = null;
            if (DoesWordContainSuffix(word, suffixes, culture)) 
            { 
                matchedSuffix = suffixes.First(s => word.EndsWith(s, true, culture));
                return true; 
            }
            else
            {
                return false; 
            }
        } 
 
        internal static bool TryInflectOnSuffixInWord(string word, IEnumerable suffixes, Func operationOnWord, CultureInfo culture, out string newWord)
        { 
            newWord = null;
            string matchedSuffixString;

            if (PluralizationServiceUtil.TryGetMatchedSuffixForWord( 
                    word,
                    suffixes, 
                    culture, out matchedSuffixString)) 
            {
                newWord = operationOnWord(word); 
                return true;
            }
            else
            { 
                return false;
            } 
        } 

    } 
}

// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
                        

Link Menu

Network programming in C#, Network Programming in VB.NET, Network Programming in .NET
This book is available now!
Buy at Amazon US or
Buy at Amazon UK