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 / Common / EntitySql / Identifier.cs / 1 / Identifier.cs
//----------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// @owner [....]
// @backup [....]
//---------------------------------------------------------------------
namespace System.Data.Common.EntitySql
{
using System;
using System.Globalization;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
///
/// represents identifier
///
internal sealed class Identifier : Expr
{
private string _name;
private bool _isEscaped;
///
/// initializes identifier
///
///
///
///
///
internal Identifier( string symbol, bool isEscaped, string query, int inputPos )
: base(query, inputPos)
{
ValidateIdentifier(symbol, isEscaped);
_name = symbol;
_isEscaped = isEscaped;
}
///
/// returns identifier name (without escaping chars if escaped id)
///
internal string Name
{
get { return (IsEscaped) ? _name.Substring(1, _name.Length - 2) : _name; }
}
///
/// returns original identifier name
///
internal string OriginalName
{
get { return _name; }
}
///
/// returns if an identifier is escaped
///
internal bool IsEscaped
{
get { return _isEscaped; }
}
private void ValidateIdentifier( string symbol, bool isEscaped )
{
if (isEscaped)
{
Debug.Assert(!String.IsNullOrEmpty(symbol), "!String.IsNullOrEmpty(symbol)");
if (symbol[0] != '[' || symbol[symbol.Length - 1] != ']')
{
throw EntityUtil.EntitySqlError(this.ErrCtx, System.Data.Entity.Strings.InvalidEscapedIdentifier(symbol));
}
}
else
{
// this is a special case since our language grammar does NOT allow [] to be used as
// part of identifiers, but it is needed for Byte[] as type identifier. The only case when
// [] will show up at the end as in 'System.Byte[]'
if (symbol.Length > 1 &&
symbol[symbol.Length - 2] == '[' &&
symbol[symbol.Length - 1] == ']')
{
symbol = symbol.Substring(0, symbol.Length - 2);
}
bool isIdentifierASCII = true;
if (!CqlLexer.IsLetterOrDigitOrUnderscore(symbol, out isIdentifierASCII))
{
if (isIdentifierASCII)
{
throw EntityUtil.EntitySqlError(this.ErrCtx, System.Data.Entity.Strings.InvalidSimpleIdentifier(symbol));
}
else
{
throw EntityUtil.EntitySqlError(this.ErrCtx, System.Data.Entity.Strings.InvalidSimpleIdentifierNonASCII(symbol));
}
}
}
}
}
///
/// represents dotted identifier
///
internal sealed class DottedIdentifier : Expr
{
private List _identifiers = new List();
private string[] _names;
private string _fullName;
///
/// intializes singleton dot identifier => simple id
///
///
internal DottedIdentifier( Identifier id )
{
_identifiers.Add(id);
_names = new string[] { id.Name };
_fullName = id.Name;
ErrCtx = id.ErrCtx;
}
///
/// intializes dot identifier from dot expression
///
///
internal DottedIdentifier( DotExpr dotExpr )
{
_names = dotExpr.Names;
_fullName = dotExpr.FullName;
Expr expr = dotExpr;
while (expr is DotExpr)
{
DotExpr newDotExpr = (DotExpr)expr;
_identifiers.Add(newDotExpr.Identifier);
expr = newDotExpr.Left;
}
_identifiers.Add((Identifier)expr);
_identifiers.Reverse();
ErrCtx = expr.ErrCtx;
ErrCtx.ErrorContextInfo = EntityRes.CtxIdentifier;
}
///
/// returns fqn as single string
///
internal string FullName
{
get { return _fullName; }
}
///
/// returns array of names
///
internal string[] Names
{
get { return _names; }
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
//----------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// @owner [....]
// @backup [....]
//---------------------------------------------------------------------
namespace System.Data.Common.EntitySql
{
using System;
using System.Globalization;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
///
/// represents identifier
///
internal sealed class Identifier : Expr
{
private string _name;
private bool _isEscaped;
///
/// initializes identifier
///
///
///
///
///
internal Identifier( string symbol, bool isEscaped, string query, int inputPos )
: base(query, inputPos)
{
ValidateIdentifier(symbol, isEscaped);
_name = symbol;
_isEscaped = isEscaped;
}
///
/// returns identifier name (without escaping chars if escaped id)
///
internal string Name
{
get { return (IsEscaped) ? _name.Substring(1, _name.Length - 2) : _name; }
}
///
/// returns original identifier name
///
internal string OriginalName
{
get { return _name; }
}
///
/// returns if an identifier is escaped
///
internal bool IsEscaped
{
get { return _isEscaped; }
}
private void ValidateIdentifier( string symbol, bool isEscaped )
{
if (isEscaped)
{
Debug.Assert(!String.IsNullOrEmpty(symbol), "!String.IsNullOrEmpty(symbol)");
if (symbol[0] != '[' || symbol[symbol.Length - 1] != ']')
{
throw EntityUtil.EntitySqlError(this.ErrCtx, System.Data.Entity.Strings.InvalidEscapedIdentifier(symbol));
}
}
else
{
// this is a special case since our language grammar does NOT allow [] to be used as
// part of identifiers, but it is needed for Byte[] as type identifier. The only case when
// [] will show up at the end as in 'System.Byte[]'
if (symbol.Length > 1 &&
symbol[symbol.Length - 2] == '[' &&
symbol[symbol.Length - 1] == ']')
{
symbol = symbol.Substring(0, symbol.Length - 2);
}
bool isIdentifierASCII = true;
if (!CqlLexer.IsLetterOrDigitOrUnderscore(symbol, out isIdentifierASCII))
{
if (isIdentifierASCII)
{
throw EntityUtil.EntitySqlError(this.ErrCtx, System.Data.Entity.Strings.InvalidSimpleIdentifier(symbol));
}
else
{
throw EntityUtil.EntitySqlError(this.ErrCtx, System.Data.Entity.Strings.InvalidSimpleIdentifierNonASCII(symbol));
}
}
}
}
}
///
/// represents dotted identifier
///
internal sealed class DottedIdentifier : Expr
{
private List _identifiers = new List();
private string[] _names;
private string _fullName;
///
/// intializes singleton dot identifier => simple id
///
///
internal DottedIdentifier( Identifier id )
{
_identifiers.Add(id);
_names = new string[] { id.Name };
_fullName = id.Name;
ErrCtx = id.ErrCtx;
}
///
/// intializes dot identifier from dot expression
///
///
internal DottedIdentifier( DotExpr dotExpr )
{
_names = dotExpr.Names;
_fullName = dotExpr.FullName;
Expr expr = dotExpr;
while (expr is DotExpr)
{
DotExpr newDotExpr = (DotExpr)expr;
_identifiers.Add(newDotExpr.Identifier);
expr = newDotExpr.Left;
}
_identifiers.Add((Identifier)expr);
_identifiers.Reverse();
ErrCtx = expr.ErrCtx;
ErrCtx.ErrorContextInfo = EntityRes.CtxIdentifier;
}
///
/// returns fqn as single string
///
internal string FullName
{
get { return _fullName; }
}
///
/// returns array of names
///
internal string[] Names
{
get { return _names; }
}
}
}
// 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
- SystemPens.cs
- ListViewItem.cs
- DiscoveryEndpoint.cs
- ProjectedSlot.cs
- _SingleItemRequestCache.cs
- odbcmetadatacolumnnames.cs
- Double.cs
- HintTextMaxWidthConverter.cs
- SchemaCollectionCompiler.cs
- FieldDescriptor.cs
- InputReferenceExpression.cs
- ToolStripSeparatorRenderEventArgs.cs
- TimeZoneInfo.cs
- SuppressMergeCheckAttribute.cs
- WpfWebRequestHelper.cs
- SymmetricKey.cs
- Helper.cs
- FormViewInsertedEventArgs.cs
- TypedReference.cs
- MailBnfHelper.cs
- NativeCompoundFileAPIs.cs
- ServiceMemoryGates.cs
- WaitHandle.cs
- RelativeSource.cs
- OraclePermissionAttribute.cs
- CodeNamespaceCollection.cs
- DetailsView.cs
- ExternalFile.cs
- Container.cs
- ChangeBlockUndoRecord.cs
- InternalPermissions.cs
- wgx_sdk_version.cs
- ColorAnimation.cs
- DataError.cs
- HtmlSelect.cs
- SettingsProperty.cs
- XPathParser.cs
- RolePrincipal.cs
- SmtpNetworkElement.cs
- InternalRelationshipCollection.cs
- EditorBrowsableAttribute.cs
- ComContractElementCollection.cs
- MimeObjectFactory.cs
- MemberMaps.cs
- NameScopePropertyAttribute.cs
- UnsafeNativeMethods.cs
- Asn1IntegerConverter.cs
- EpmContentSerializerBase.cs
- ApplicationManager.cs
- WebPartTransformerAttribute.cs
- ServiceErrorHandler.cs
- CompoundFileStreamReference.cs
- TextEffectResolver.cs
- MembershipSection.cs
- IISMapPath.cs
- QuaternionAnimation.cs
- GridViewAutomationPeer.cs
- TransactedBatchingBehavior.cs
- CultureInfo.cs
- MsmqNonTransactedPoisonHandler.cs
- EditorPart.cs
- _NetworkingPerfCounters.cs
- ProcessHostMapPath.cs
- isolationinterop.cs
- QilXmlWriter.cs
- MouseButton.cs
- View.cs
- RequestCachePolicy.cs
- DataRelationCollection.cs
- TTSEvent.cs
- HostProtectionPermission.cs
- MD5HashHelper.cs
- SelectorItemAutomationPeer.cs
- DeflateStream.cs
- Dynamic.cs
- SignatureResourceHelper.cs
- AspNetPartialTrustHelpers.cs
- WindowsListView.cs
- DrawingAttributesDefaultValueFactory.cs
- BrowserCapabilitiesCodeGenerator.cs
- Vector3DIndependentAnimationStorage.cs
- LinqToSqlWrapper.cs
- PageBuildProvider.cs
- ColorConverter.cs
- DateTimeConverter2.cs
- XamlValidatingReader.cs
- UIInitializationException.cs
- UserValidatedEventArgs.cs
- EdmType.cs
- Light.cs
- ProfessionalColorTable.cs
- OracleDateTime.cs
- CurrentTimeZone.cs
- RbTree.cs
- ArrangedElementCollection.cs
- TypeEnumerableViewSchema.cs
- NamedObjectList.cs
- MultiPropertyDescriptorGridEntry.cs
- GroupStyle.cs
- PanelStyle.cs