Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / Orcas / NetFXw7 / 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
- RepeaterItemEventArgs.cs
- WizardForm.cs
- GeneralTransform3DTo2D.cs
- ColumnResizeAdorner.cs
- Registration.cs
- UxThemeWrapper.cs
- diagnosticsswitches.cs
- DoubleAnimationUsingPath.cs
- HebrewCalendar.cs
- DelimitedListTraceListener.cs
- Helper.cs
- CryptoConfig.cs
- SqlTriggerAttribute.cs
- Nullable.cs
- IntegrationExceptionEventArgs.cs
- Translator.cs
- EventsTab.cs
- ClientTarget.cs
- DbProviderFactory.cs
- MiniParameterInfo.cs
- RelatedPropertyManager.cs
- SelectionProviderWrapper.cs
- HtmlElementCollection.cs
- Token.cs
- sitestring.cs
- HttpPostedFile.cs
- ReadOnlyDictionary.cs
- HashFinalRequest.cs
- AttributeCollection.cs
- EntityDataSourceChangingEventArgs.cs
- ArrayWithOffset.cs
- UnsafeNativeMethods.cs
- MemoryPressure.cs
- ExceptionValidationRule.cs
- SmtpReplyReaderFactory.cs
- QueryAccessibilityHelpEvent.cs
- TrackingAnnotationCollection.cs
- EDesignUtil.cs
- PointLight.cs
- Mappings.cs
- SystemWebSectionGroup.cs
- CommandEventArgs.cs
- ConfigurationValidatorAttribute.cs
- WmlImageAdapter.cs
- InvalidOleVariantTypeException.cs
- ConfigurationStrings.cs
- SelectedDatesCollection.cs
- ConfigurationCollectionAttribute.cs
- DataControlPagerLinkButton.cs
- BigInt.cs
- SHA512.cs
- NonBatchDirectoryCompiler.cs
- ModuleConfigurationInfo.cs
- SchemaAttDef.cs
- ParameterBinding.cs
- DockPattern.cs
- FigureHelper.cs
- ToolStripSettings.cs
- XmlSerializationGeneratedCode.cs
- JavascriptXmlWriterWrapper.cs
- SafePEFileHandle.cs
- DropTarget.cs
- UInt32Storage.cs
- FixedSOMElement.cs
- ConditionalBranch.cs
- WhitespaceSignificantCollectionAttribute.cs
- ColumnHeader.cs
- LocalizabilityAttribute.cs
- RectConverter.cs
- StructuredTypeInfo.cs
- ApplicationManager.cs
- WebSysDescriptionAttribute.cs
- ReaderContextStackData.cs
- HtmlTernaryTree.cs
- ToolStripDropDown.cs
- RetrieveVirtualItemEventArgs.cs
- SubstitutionList.cs
- ClientScriptManager.cs
- ProfileGroupSettings.cs
- ToolStripSettings.cs
- StringPropertyBuilder.cs
- SimpleType.cs
- ListViewContainer.cs
- CachedPathData.cs
- TextContainer.cs
- InternalSafeNativeMethods.cs
- URLMembershipCondition.cs
- TreeViewItem.cs
- PropertyChangingEventArgs.cs
- SqlPersonalizationProvider.cs
- DebugViewWriter.cs
- Int32CAMarshaler.cs
- Effect.cs
- PriorityQueue.cs
- HybridObjectCache.cs
- AvTraceDetails.cs
- RedBlackList.cs
- PointAnimationBase.cs
- ViewCellRelation.cs
- UriScheme.cs