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
- DataGridViewDataErrorEventArgs.cs
- EventWaitHandleSecurity.cs
- GregorianCalendar.cs
- ProtocolsConfiguration.cs
- WebResponse.cs
- TextCollapsingProperties.cs
- ScriptingAuthenticationServiceSection.cs
- Exceptions.cs
- JoinCqlBlock.cs
- RawKeyboardInputReport.cs
- SchemaNamespaceManager.cs
- OdbcErrorCollection.cs
- ParamArrayAttribute.cs
- ComplexType.cs
- SequenceFullException.cs
- DetailsViewPageEventArgs.cs
- PointCollection.cs
- XmlElementAttributes.cs
- TextParagraphProperties.cs
- Application.cs
- ProvidersHelper.cs
- BoolExpr.cs
- Types.cs
- ResXDataNode.cs
- EmptyReadOnlyDictionaryInternal.cs
- FileAuthorizationModule.cs
- DataGridViewColumnHeaderCell.cs
- DbUpdateCommandTree.cs
- EncryptedKey.cs
- CommonGetThemePartSize.cs
- ConsumerConnectionPointCollection.cs
- Separator.cs
- X509Certificate2Collection.cs
- TextSelectionHelper.cs
- SQLCharsStorage.cs
- XNameTypeConverter.cs
- UpdatePanelTrigger.cs
- InternalPermissions.cs
- HMAC.cs
- UrlPath.cs
- ProtocolsConfiguration.cs
- DataControlCommands.cs
- ServicePointManager.cs
- PublishLicense.cs
- ManagementInstaller.cs
- Substitution.cs
- TextViewDesigner.cs
- CodeTypeOfExpression.cs
- SqlDeflator.cs
- SecurityTokenReferenceStyle.cs
- XmlChildEnumerator.cs
- PasswordRecovery.cs
- NavigationEventArgs.cs
- TemplateBindingExpression.cs
- ElementUtil.cs
- Listener.cs
- BookmarkScopeInfo.cs
- CreateUserWizardAutoFormat.cs
- ParameterBuilder.cs
- PropertySegmentSerializer.cs
- ColorConvertedBitmap.cs
- WorkflowRuntimeServiceElementCollection.cs
- CopyNodeSetAction.cs
- DataGridViewComboBoxColumn.cs
- Light.cs
- AsyncPostBackTrigger.cs
- XPathExpr.cs
- TraceHelpers.cs
- DomainUpDown.cs
- ObjectDataSource.cs
- WebEventTraceProvider.cs
- ObjectStateEntryOriginalDbUpdatableDataRecord.cs
- DataKeyArray.cs
- FontInfo.cs
- SizeAnimation.cs
- DateTimeUtil.cs
- FixedPageProcessor.cs
- FastEncoder.cs
- SoapFormatExtensions.cs
- XmlAttributes.cs
- FontUnit.cs
- RectAnimationClockResource.cs
- CommonGetThemePartSize.cs
- contentDescriptor.cs
- ReflectionPermission.cs
- ConnectorDragDropGlyph.cs
- TextParaClient.cs
- TraceContext.cs
- wmiprovider.cs
- AdornerDecorator.cs
- MessageEncoderFactory.cs
- BitmapCodecInfo.cs
- WCFServiceClientProxyGenerator.cs
- ProfilePropertyMetadata.cs
- FilterQueryOptionExpression.cs
- ObjectManager.cs
- ConfigXmlCDataSection.cs
- TypeUtil.cs
- JsonFormatReaderGenerator.cs
- CapabilitiesRule.cs