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
- ObjectMaterializedEventArgs.cs
- DockingAttribute.cs
- InfoCardRSAPKCS1KeyExchangeDeformatter.cs
- Duration.cs
- FloatSumAggregationOperator.cs
- x509store.cs
- ChtmlTextWriter.cs
- DataBindingCollection.cs
- OnOperation.cs
- MergeFilterQuery.cs
- EntityContainerAssociationSet.cs
- DataViewManagerListItemTypeDescriptor.cs
- CompleteWizardStep.cs
- BamlStream.cs
- CultureSpecificStringDictionary.cs
- Content.cs
- MbpInfo.cs
- AuthorizationSection.cs
- ConnectionPoint.cs
- AtomServiceDocumentSerializer.cs
- RightsManagementInformation.cs
- CodeExpressionRuleDeclaration.cs
- XslAstAnalyzer.cs
- MimeMapping.cs
- VirtualPathData.cs
- DiscriminatorMap.cs
- GPRECTF.cs
- TextEmbeddedObject.cs
- HierarchicalDataTemplate.cs
- PackWebResponse.cs
- Adorner.cs
- CharacterBuffer.cs
- SafeRegistryHandle.cs
- TargetFrameworkAttribute.cs
- SqlRewriteScalarSubqueries.cs
- NominalTypeEliminator.cs
- Expressions.cs
- TextServicesCompartmentEventSink.cs
- MulticastDelegate.cs
- UIElement.cs
- PanelStyle.cs
- DataGridViewComboBoxCell.cs
- ContextMenuStrip.cs
- ParameterDataSourceExpression.cs
- TypeConverterHelper.cs
- FrameworkElement.cs
- PropertyCollection.cs
- ImpersonateTokenRef.cs
- ValueSerializer.cs
- GenericNameHandler.cs
- ResourcesGenerator.cs
- EdmItemError.cs
- HttpDebugHandler.cs
- EntryIndex.cs
- ImportCatalogPart.cs
- DependencyObjectCodeDomSerializer.cs
- IndicCharClassifier.cs
- Range.cs
- ConfigurationStrings.cs
- CodeSnippetTypeMember.cs
- CompilerWrapper.cs
- EmptyCollection.cs
- Graphics.cs
- XmlSchemaAnnotated.cs
- _BufferOffsetSize.cs
- SharedUtils.cs
- String.cs
- VirtualPath.cs
- SqlReferenceCollection.cs
- GrammarBuilderDictation.cs
- IApplicationTrustManager.cs
- PeerCustomResolverBindingElement.cs
- Byte.cs
- QilLoop.cs
- GenerateScriptTypeAttribute.cs
- AffineTransform3D.cs
- UserControlParser.cs
- HyperLink.cs
- PointConverter.cs
- FontWeightConverter.cs
- FlowPanelDesigner.cs
- ChildDocumentBlock.cs
- ValueSerializerAttribute.cs
- MemoryMappedFile.cs
- ToolStripPanelRenderEventArgs.cs
- DataControlFieldsEditor.cs
- DataRecordObjectView.cs
- LogExtent.cs
- DesignerLoader.cs
- AnimationLayer.cs
- DictationGrammar.cs
- ResourceAttributes.cs
- DataServiceClientException.cs
- BamlResourceDeserializer.cs
- OdbcParameterCollection.cs
- Rotation3D.cs
- PriorityBinding.cs
- HtmlButton.cs
- StringFunctions.cs
- ExpressionDumper.cs