Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / DataEntity / System / Data / Map / ViewGeneration / CqlGeneration / CqlIdentifiers.cs / 1305376 / CqlIdentifiers.cs
//---------------------------------------------------------------------- //// Copyright (c) Microsoft Corporation. All rights reserved. // // // @owner [....] // @backupOwner [....] //--------------------------------------------------------------------- using System.Data.Common.Utils; using System.Text; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; namespace System.Data.Mapping.ViewGeneration.Structures { // This class is responsible for ensuring unique aliases for _from0, etc // and block aliases T, T0, T1, etc internal class CqlIdentifiers : InternalBase { #region Constructor internal CqlIdentifiers() { m_identifiers = new Set(StringComparer.Ordinal); } #endregion #region Fields private Set m_identifiers; #endregion #region Methods // effects: Given a number, returns _from if it does not clashes with // any identifier, else returns _from_ _ where is the first number from 0 // where there is no clash internal string GetFromVariable(int num) { return GetNonConflictingName("_from", num); } // effects: Given a number, returns T if it does not clashes with // any identifier, else returns T_ _ where is the first number from 0 // where there is no clash internal string GetBlockAlias(int num) { return GetNonConflictingName("T", num); } // effects: Given a number, returns T if it does not clashes with // any identifier, else returns T_ where is the first number from 0 // where there is no clash internal string GetBlockAlias() { return GetNonConflictingName("T", -1); } [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1308:NormalizeStringsToUppercase")] internal void AddIdentifier(string identifier) { m_identifiers.Add(identifier.ToLower(CultureInfo.InvariantCulture)); } [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1308:NormalizeStringsToUppercase")] private string GetNonConflictingName(string prefix, int number) { // Do a case sensitive search but return the string that uses the // original prefix string result = number < 0 ? prefix : StringUtil.FormatInvariant("{0}{1}", prefix, number); // Check if the prefix exists or not if (m_identifiers.Contains(result.ToLower(CultureInfo.InvariantCulture)) == false) { return result; } // Go through integers and find the first one that does not clash for (int count = 0; count < int.MaxValue; count++) { if (number < 0) { result = StringUtil.FormatInvariant("{0}_{1}", prefix, count); } else { result = StringUtil.FormatInvariant("{0}_{1}_{2}", prefix, count, number); } if (m_identifiers.Contains(result.ToLower(CultureInfo.InvariantCulture)) == false) { return result; } } Debug.Fail("Found no unique _from till MaxValue?"); return null; } internal override void ToCompactString(StringBuilder builder) { m_identifiers.ToCompactString(builder); } #endregion } } // 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
- TripleDES.cs
- MtomMessageEncodingElement.cs
- OpenTypeLayout.cs
- Blend.cs
- XomlCompilerHelpers.cs
- HttpCacheVary.cs
- ElementHostAutomationPeer.cs
- CultureTableRecord.cs
- FixedSOMTextRun.cs
- RawMouseInputReport.cs
- EventHandlingScope.cs
- ColumnClickEvent.cs
- GrammarBuilderWildcard.cs
- XamlSerializerUtil.cs
- GiveFeedbackEventArgs.cs
- MimeTypeAttribute.cs
- AuthenticationService.cs
- SerializationHelper.cs
- ReadWriteObjectLock.cs
- EventlogProvider.cs
- _NestedMultipleAsyncResult.cs
- StateFinalizationActivity.cs
- SqlDataSourceCache.cs
- Activator.cs
- ControlIdConverter.cs
- AvTraceFormat.cs
- _ListenerResponseStream.cs
- WeakReadOnlyCollection.cs
- CreationContext.cs
- ToolStripItemEventArgs.cs
- SafeRegistryKey.cs
- PointIndependentAnimationStorage.cs
- ContentDisposition.cs
- XmlAggregates.cs
- SortQuery.cs
- ImageIndexConverter.cs
- WindowsButton.cs
- TemplateInstanceAttribute.cs
- FloaterParaClient.cs
- FileSecurity.cs
- ConstraintConverter.cs
- XmlAttributes.cs
- HostingEnvironmentWrapper.cs
- IChannel.cs
- SecurityElement.cs
- WCFModelStrings.Designer.cs
- DictionaryTraceRecord.cs
- XmlText.cs
- ColorConvertedBitmap.cs
- MemoryPressure.cs
- OperandQuery.cs
- UpdateDelegates.Generated.cs
- UpdateRecord.cs
- JsonFormatMapping.cs
- RIPEMD160Managed.cs
- AlternateView.cs
- CellPartitioner.cs
- _BasicClient.cs
- SqlGenerator.cs
- TreeNodeCollection.cs
- latinshape.cs
- EventLogger.cs
- ImageMap.cs
- ContainerFilterService.cs
- ColorTypeConverter.cs
- RC2CryptoServiceProvider.cs
- FrameAutomationPeer.cs
- MetadataFile.cs
- ToolboxComponentsCreatingEventArgs.cs
- XmlnsDictionary.cs
- CallbackValidatorAttribute.cs
- EdmFunctions.cs
- HttpApplicationFactory.cs
- XmlSchemaSubstitutionGroup.cs
- RepeatBehaviorConverter.cs
- DataSourceCache.cs
- RsaSecurityKey.cs
- WindowsToolbar.cs
- ImagingCache.cs
- ProviderMetadata.cs
- PassportAuthentication.cs
- PersonalizationEntry.cs
- StylusPointPropertyInfoDefaults.cs
- CodeAttributeDeclaration.cs
- DataListCommandEventArgs.cs
- StrongTypingException.cs
- AutomationIdentifier.cs
- WorkflowNamespace.cs
- XmlSchemaAny.cs
- ConstraintCollection.cs
- GraphicsContainer.cs
- TdsParserSafeHandles.cs
- StreamWithDictionary.cs
- DeploymentSection.cs
- _StreamFramer.cs
- StateDesigner.Layouts.cs
- MatrixAnimationBase.cs
- TypeSemantics.cs
- MethodAccessException.cs
- OutgoingWebRequestContext.cs