Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / DataEntity / System / Data / Map / ViewGeneration / CqlGeneration / CqlWriter.cs / 1305376 / CqlWriter.cs
//----------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// @owner [....]
// @backupOwner [....]
//---------------------------------------------------------------------
using System.Text.RegularExpressions;
using System.Text;
using System.Data.Common.Utils;
using System.Data.Mapping.ViewGeneration.Utils;
using System.Data.Metadata.Edm;
namespace System.Data.Mapping.ViewGeneration.CqlGeneration
{
// This class contains helper methods needed for generating Cql
internal static class CqlWriter
{
#region Fields
private static readonly Regex s_wordIdentifierRegex = new Regex(@"^[_A-Za-z]\w*$", RegexOptions.ECMAScript | RegexOptions.Compiled);
#endregion
#region Helper Methods
// effects: Given a block name and a field in it -- returns a string
// of form "blockName.field". Does not perform any escaping
internal static string GetQualifiedName(string blockName, string field)
{
string result = StringUtil.FormatInvariant("{0}.{1}", blockName, field);
return result;
}
// effects: Modifies builder to contain an escaped version of type's name as "[namespace.typename]"
internal static void AppendEscapedTypeName(StringBuilder builder, EdmType type)
{
AppendEscapedName(builder, GetQualifiedName(type.NamespaceName, type.Name));
}
// effects: Modifies builder to contain an escaped version of "name1.name2" as "[name1].[name2]"
internal static void AppendEscapedQualifiedName(StringBuilder builder, string name1, string name2)
{
AppendEscapedName(builder, name1);
builder.Append('.');
AppendEscapedName(builder, name2);
}
// effects: Modifies builder to contain an escaped version of "name"
internal static void AppendEscapedName(StringBuilder builder, string name)
{
if (s_wordIdentifierRegex.IsMatch(name) && false == ExternalCalls.IsReservedKeyword(name))
{
// We do not need to escape the name if it is a simple name and it is not a keyword
builder.Append(name);
}
else
{
string newName = name.Replace("]", "]]");
builder.Append('[')
.Append(newName)
.Append(']');
}
}
#endregion
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
//----------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// @owner [....]
// @backupOwner [....]
//---------------------------------------------------------------------
using System.Text.RegularExpressions;
using System.Text;
using System.Data.Common.Utils;
using System.Data.Mapping.ViewGeneration.Utils;
using System.Data.Metadata.Edm;
namespace System.Data.Mapping.ViewGeneration.CqlGeneration
{
// This class contains helper methods needed for generating Cql
internal static class CqlWriter
{
#region Fields
private static readonly Regex s_wordIdentifierRegex = new Regex(@"^[_A-Za-z]\w*$", RegexOptions.ECMAScript | RegexOptions.Compiled);
#endregion
#region Helper Methods
// effects: Given a block name and a field in it -- returns a string
// of form "blockName.field". Does not perform any escaping
internal static string GetQualifiedName(string blockName, string field)
{
string result = StringUtil.FormatInvariant("{0}.{1}", blockName, field);
return result;
}
// effects: Modifies builder to contain an escaped version of type's name as "[namespace.typename]"
internal static void AppendEscapedTypeName(StringBuilder builder, EdmType type)
{
AppendEscapedName(builder, GetQualifiedName(type.NamespaceName, type.Name));
}
// effects: Modifies builder to contain an escaped version of "name1.name2" as "[name1].[name2]"
internal static void AppendEscapedQualifiedName(StringBuilder builder, string name1, string name2)
{
AppendEscapedName(builder, name1);
builder.Append('.');
AppendEscapedName(builder, name2);
}
// effects: Modifies builder to contain an escaped version of "name"
internal static void AppendEscapedName(StringBuilder builder, string name)
{
if (s_wordIdentifierRegex.IsMatch(name) && false == ExternalCalls.IsReservedKeyword(name))
{
// We do not need to escape the name if it is a simple name and it is not a keyword
builder.Append(name);
}
else
{
string newName = name.Replace("]", "]]");
builder.Append('[')
.Append(newName)
.Append(']');
}
}
#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
- StylusCaptureWithinProperty.cs
- RowParagraph.cs
- OrthographicCamera.cs
- HMACRIPEMD160.cs
- HtmlInputSubmit.cs
- CodeArgumentReferenceExpression.cs
- PixelFormat.cs
- AnnotationResource.cs
- XmlAtomicValue.cs
- SecurityDocument.cs
- MarkupCompilePass1.cs
- Attributes.cs
- QueryExecutionOption.cs
- WebServiceClientProxyGenerator.cs
- Rect.cs
- SimpleMailWebEventProvider.cs
- SafeNativeHandle.cs
- ListItemCollection.cs
- WinInetCache.cs
- TryCatch.cs
- PtsPage.cs
- HttpModuleAction.cs
- Debug.cs
- UnicodeEncoding.cs
- CallbackValidatorAttribute.cs
- RequestBringIntoViewEventArgs.cs
- RoutedEventHandlerInfo.cs
- RadioButtonList.cs
- FormatConvertedBitmap.cs
- ToolStripItemTextRenderEventArgs.cs
- HttpConfigurationSystem.cs
- AuthenticationManager.cs
- NumericPagerField.cs
- Brush.cs
- DrawingDrawingContext.cs
- RefType.cs
- TabControlEvent.cs
- TextElementEnumerator.cs
- CommandID.cs
- ProcessHostMapPath.cs
- SoapSchemaMember.cs
- NameScopePropertyAttribute.cs
- SqlUnionizer.cs
- PerfService.cs
- HwndSource.cs
- MetadataUtil.cs
- HttpCacheVaryByContentEncodings.cs
- NopReturnReader.cs
- XmlSchemaComplexContent.cs
- HostVisual.cs
- MarkerProperties.cs
- XmlWriterSettings.cs
- RC2.cs
- safemediahandle.cs
- CharKeyFrameCollection.cs
- Underline.cs
- EllipseGeometry.cs
- Calendar.cs
- XslAstAnalyzer.cs
- XpsPartBase.cs
- ClientTarget.cs
- PackagingUtilities.cs
- ScrollPattern.cs
- PrtTicket_Public.cs
- RemotingServices.cs
- OverflowException.cs
- XmlSchemaAttributeGroup.cs
- DelegatingMessage.cs
- SerialReceived.cs
- ResourceContainerWrapper.cs
- MULTI_QI.cs
- SqlNodeTypeOperators.cs
- _CacheStreams.cs
- StorageAssociationSetMapping.cs
- SortDescription.cs
- mediaeventshelper.cs
- ObjectQueryState.cs
- ProtocolsSection.cs
- RectKeyFrameCollection.cs
- CreateUserWizardStep.cs
- TransformProviderWrapper.cs
- SpecialNameAttribute.cs
- SendActivityDesignerTheme.cs
- XmlSchemaExporter.cs
- TimeSpan.cs
- ListViewItemSelectionChangedEvent.cs
- CapabilitiesAssignment.cs
- RequestCacheValidator.cs
- InvalidDataException.cs
- DataGridTable.cs
- SecurityTokenResolver.cs
- DynamicQueryableWrapper.cs
- MatrixAnimationUsingPath.cs
- DropShadowBitmapEffect.cs
- UIElement3DAutomationPeer.cs
- EventLogPermissionAttribute.cs
- PrintDialog.cs
- QilTargetType.cs
- DateTimeFormatInfo.cs
- TextEffectCollection.cs