Code:
/ 4.0 / 4.0 / 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.
//----------------------------------------------------------------------
//
// 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

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- Vector3dCollection.cs
- CollectionEditorDialog.cs
- HttpCookieCollection.cs
- GridItemCollection.cs
- ExpressionConverter.cs
- CompositeCollection.cs
- BaseTemplatedMobileComponentEditor.cs
- TemplatedControlDesigner.cs
- GlyphingCache.cs
- FileLogRecordStream.cs
- XmlTypeMapping.cs
- QilXmlWriter.cs
- PropertyChangingEventArgs.cs
- WebProxyScriptElement.cs
- GifBitmapDecoder.cs
- Certificate.cs
- SqlMethodCallConverter.cs
- FrameworkReadOnlyPropertyMetadata.cs
- WebPartDescription.cs
- ArcSegment.cs
- NamespaceCollection.cs
- AppSecurityManager.cs
- CommandConverter.cs
- WinFormsSpinner.cs
- MetadataSerializer.cs
- DataExpression.cs
- HttpWrapper.cs
- PropertyChangedEventArgs.cs
- LocalizableAttribute.cs
- TabletDeviceInfo.cs
- ConfigurationException.cs
- PointUtil.cs
- InfoCardArgumentException.cs
- PackageRelationshipCollection.cs
- ToolStripArrowRenderEventArgs.cs
- ModelTreeEnumerator.cs
- StringOutput.cs
- GraphicsPath.cs
- CompareInfo.cs
- ScriptingJsonSerializationSection.cs
- DesignerOptionService.cs
- SplitterDesigner.cs
- SaveWorkflowAsyncResult.cs
- sqlstateclientmanager.cs
- ValidationEventArgs.cs
- CodeDomConfigurationHandler.cs
- ObjectViewEntityCollectionData.cs
- thaishape.cs
- _DisconnectOverlappedAsyncResult.cs
- BlobPersonalizationState.cs
- PrincipalPermission.cs
- DataConnectionHelper.cs
- ServicePointManager.cs
- AdapterDictionary.cs
- SafeEventLogReadHandle.cs
- WebPartPersonalization.cs
- FixedSOMTableCell.cs
- EnumerableRowCollection.cs
- ItemAutomationPeer.cs
- SerializationException.cs
- shaperfactoryquerycacheentry.cs
- SendOperation.cs
- ComplexPropertyEntry.cs
- WebBrowserContainer.cs
- InlineCollection.cs
- FilterQueryOptionExpression.cs
- UpdateProgress.cs
- DataStreamFromComStream.cs
- ExtensibleClassFactory.cs
- FrameAutomationPeer.cs
- ScriptHandlerFactory.cs
- SchemaNames.cs
- EventLogEntry.cs
- VariableAction.cs
- BinaryFormatter.cs
- TransactedBatchContext.cs
- ProviderConnectionPointCollection.cs
- FacetDescriptionElement.cs
- ServiceSecurityAuditBehavior.cs
- TCPListener.cs
- RunWorkerCompletedEventArgs.cs
- SerializationAttributes.cs
- HttpWebRequestElement.cs
- OverrideMode.cs
- DesignerCapabilities.cs
- LabelAutomationPeer.cs
- SqlProfileProvider.cs
- CollectionEditor.cs
- SharedStatics.cs
- TextUtf8RawTextWriter.cs
- CacheChildrenQuery.cs
- followingsibling.cs
- SiteMapProvider.cs
- Separator.cs
- DBDataPermissionAttribute.cs
- ItemMap.cs
- Merger.cs
- PropertyPathWorker.cs
- SafeCryptoHandles.cs
- ThicknessKeyFrameCollection.cs