Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / Orcas / QFE / ndp / fx / src / DataEntity / System / Data / Map / ViewGeneration / CqlGeneration / CqlIdentifiers.cs / 1 / 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); } internal void AddIdentifier(string identifier) { m_identifiers.Add(identifier.ToLower(CultureInfo.InvariantCulture)); } 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. //---------------------------------------------------------------------- // // 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); } internal void AddIdentifier(string identifier) { m_identifiers.Add(identifier.ToLower(CultureInfo.InvariantCulture)); } 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
- ThousandthOfEmRealPoints.cs
- CollectionChangedEventManager.cs
- LicenseException.cs
- ReadingWritingEntityEventArgs.cs
- XmlCharCheckingReader.cs
- Convert.cs
- EncodingInfo.cs
- IOException.cs
- DataGridSortCommandEventArgs.cs
- FileSystemEnumerable.cs
- GeneralTransform3DGroup.cs
- Renderer.cs
- DataRowExtensions.cs
- DataBoundControlAdapter.cs
- CultureInfoConverter.cs
- connectionpool.cs
- FontSource.cs
- WriteStateInfoBase.cs
- ServiceParser.cs
- DateTimeFormatInfo.cs
- EventProviderTraceListener.cs
- TextParagraphProperties.cs
- RuntimeConfigurationRecord.cs
- EventProviderWriter.cs
- RbTree.cs
- XmlNamedNodeMap.cs
- ItemChangedEventArgs.cs
- ContentDesigner.cs
- PageWrapper.cs
- WebBrowserSiteBase.cs
- WorkflowNamespace.cs
- BypassElementCollection.cs
- SortedList.cs
- EncoderParameters.cs
- RuntimeEnvironment.cs
- SignHashRequest.cs
- RenderCapability.cs
- ByteFacetDescriptionElement.cs
- Matrix3DConverter.cs
- HttpResponseMessageProperty.cs
- DebugView.cs
- XmlUtil.cs
- WebPartZoneBase.cs
- TemplateControlCodeDomTreeGenerator.cs
- ObjectConverter.cs
- CipherData.cs
- SecurityException.cs
- GatewayDefinition.cs
- ProvidersHelper.cs
- WebServiceMethodData.cs
- TextBox.cs
- NameValuePair.cs
- FontClient.cs
- Int16Converter.cs
- RemotingServices.cs
- MailWriter.cs
- OdbcConnectionFactory.cs
- Missing.cs
- AdjustableArrowCap.cs
- DataGridViewTextBoxCell.cs
- HttpWrapper.cs
- WebPartDesigner.cs
- SqlDataRecord.cs
- ListenerPerfCounters.cs
- DetailsViewCommandEventArgs.cs
- ProgressiveCrcCalculatingStream.cs
- UriScheme.cs
- AsymmetricSignatureFormatter.cs
- SafeFileHandle.cs
- SHA512.cs
- XmlSchemaInferenceException.cs
- XmlSignatureManifest.cs
- FunctionImportMapping.cs
- WebPart.cs
- StoreAnnotationsMap.cs
- EventSetter.cs
- Model3D.cs
- FontFamilyIdentifier.cs
- SystemIPv4InterfaceProperties.cs
- Funcletizer.cs
- SparseMemoryStream.cs
- Latin1Encoding.cs
- SymbolPair.cs
- IsolatedStoragePermission.cs
- EmptyEnumerator.cs
- EtwTrace.cs
- TripleDESCryptoServiceProvider.cs
- BaseResourcesBuildProvider.cs
- JumpPath.cs
- MetafileHeader.cs
- IISUnsafeMethods.cs
- DesignBindingPropertyDescriptor.cs
- Executor.cs
- ColorTransform.cs
- UnionExpr.cs
- TabPageDesigner.cs
- ElementNotEnabledException.cs
- CheckBoxStandardAdapter.cs
- DataSet.cs
- SetStoryboardSpeedRatio.cs