Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / DataEntityDesign / Design / System / Data / Entity / Design / PluralizationService / BidirectionalDictionary.cs / 1305376 / BidirectionalDictionary.cs
//---------------------------------------------------------------------- //// Copyright (c) Microsoft Corporation. All rights reserved. // // // @owner [....] // @backupOwner [....] //--------------------------------------------------------------------- using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Globalization; namespace System.Data.Entity.Design.PluralizationServices { ////// This class provide service for both the singularization and pluralization, it takes the word pairs /// in the ctor following the rules that the first one is singular and the second one is plural. /// internal class BidirectionalDictionary{ internal Dictionary FirstToSecondDictionary { get; set; } internal Dictionary SecondToFirstDictionary { get; set; } internal BidirectionalDictionary() { this.FirstToSecondDictionary = new Dictionary (); this.SecondToFirstDictionary = new Dictionary (); } internal BidirectionalDictionary(Dictionary firstToSecondDictionary) : this() { foreach (var key in firstToSecondDictionary.Keys) { this.AddValue(key, firstToSecondDictionary[key]); } } internal virtual bool ExistsInFirst(TFirst value) { if (this.FirstToSecondDictionary.ContainsKey(value)) { return true; } return false; } internal virtual bool ExistsInSecond(TSecond value) { if (this.SecondToFirstDictionary.ContainsKey(value)) { return true; } return false; } internal virtual TSecond GetSecondValue(TFirst value) { if (this.ExistsInFirst(value)) { return this.FirstToSecondDictionary[value]; } else { return default(TSecond); } } internal virtual TFirst GetFirstValue(TSecond value) { if (this.ExistsInSecond(value)) { return this.SecondToFirstDictionary[value]; } else { return default(TFirst); } } internal void AddValue(TFirst firstValue, TSecond secondValue) { this.FirstToSecondDictionary.Add(firstValue, secondValue); if (!this.SecondToFirstDictionary.ContainsKey(secondValue)) { this.SecondToFirstDictionary.Add(secondValue, firstValue); } } } internal class StringBidirectionalDictionary : BidirectionalDictionary { internal StringBidirectionalDictionary() : base() { } internal StringBidirectionalDictionary(Dictionary firstToSecondDictionary) : base(firstToSecondDictionary) { } [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1308:NormalizeStringsToUppercase")] internal override bool ExistsInFirst(string value) { return base.ExistsInFirst(value.ToLowerInvariant()); } [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1308:NormalizeStringsToUppercase")] internal override bool ExistsInSecond(string value) { return base.ExistsInSecond(value.ToLowerInvariant()); } [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1308:NormalizeStringsToUppercase")] internal override string GetFirstValue(string value) { return base.GetFirstValue(value.ToLowerInvariant()); } [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1308:NormalizeStringsToUppercase")] internal override string GetSecondValue(string value) { return base.GetSecondValue(value.ToLowerInvariant()); } } } // 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
- SqlTransaction.cs
- ControlParameter.cs
- SemanticResultValue.cs
- TargetInvocationException.cs
- _LoggingObject.cs
- CatalogZoneBase.cs
- Point3DAnimation.cs
- ByteStorage.cs
- TraceHandlerErrorFormatter.cs
- StandardRuntimeEnumValidatorAttribute.cs
- BulletDecorator.cs
- IdleTimeoutMonitor.cs
- CompilerGlobalScopeAttribute.cs
- Pens.cs
- path.cs
- WmlPanelAdapter.cs
- Stylesheet.cs
- BuildProvider.cs
- EventLogRecord.cs
- BlobPersonalizationState.cs
- EpmContentDeSerializerBase.cs
- ClusterUtils.cs
- Stack.cs
- XmlArrayItemAttributes.cs
- BufferedReceiveManager.cs
- PackWebResponse.cs
- shaper.cs
- TimeSpanOrInfiniteConverter.cs
- BaseTemplateParser.cs
- XmlIgnoreAttribute.cs
- CompositeFontParser.cs
- PhoneCallDesigner.cs
- NetWebProxyFinder.cs
- DBSqlParser.cs
- CodeRegionDirective.cs
- Int16AnimationUsingKeyFrames.cs
- WCFBuildProvider.cs
- FactoryGenerator.cs
- HwndHostAutomationPeer.cs
- cookieexception.cs
- InvokeSchedule.cs
- TemplateField.cs
- TypeConverters.cs
- StateItem.cs
- CopyNodeSetAction.cs
- DataSetSchema.cs
- SecurityTokenSerializer.cs
- CalendarDataBindingHandler.cs
- TreeViewImageKeyConverter.cs
- QuadTree.cs
- XhtmlTextWriter.cs
- FileDialogCustomPlace.cs
- LogConverter.cs
- CellPartitioner.cs
- RtType.cs
- TemplateApplicationHelper.cs
- ObjectDataSource.cs
- PeerNodeTraceRecord.cs
- KerberosSecurityTokenParameters.cs
- ParallelRangeManager.cs
- OdbcParameter.cs
- EDesignUtil.cs
- cookieexception.cs
- Persist.cs
- DataErrorValidationRule.cs
- BitmapScalingModeValidation.cs
- SiteMapNodeCollection.cs
- DropSource.cs
- FieldTemplateFactory.cs
- OperationFormatStyle.cs
- ComponentEvent.cs
- BitmapMetadataBlob.cs
- CursorConverter.cs
- List.cs
- ContextMenuStrip.cs
- WindowsListViewItemCheckBox.cs
- XmlSequenceWriter.cs
- LoginCancelEventArgs.cs
- ConversionHelper.cs
- BindToObject.cs
- IncrementalCompileAnalyzer.cs
- PackageRelationshipCollection.cs
- LocationChangedEventArgs.cs
- MdiWindowListItemConverter.cs
- HttpAsyncResult.cs
- XhtmlBasicTextViewAdapter.cs
- ObjectItemCollection.cs
- ContentPlaceHolderDesigner.cs
- ApplicationDirectory.cs
- SafeThreadHandle.cs
- Models.cs
- JournalEntry.cs
- ComponentEditorPage.cs
- BaseCollection.cs
- Mapping.cs
- _NetRes.cs
- Registry.cs
- SecUtil.cs
- RemoteArgument.cs
- OletxResourceManager.cs