Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / Orcas / QFE / ndp / fx / src / DataWeb / Server / System / Data / Services / Parsing / Token.cs / 1 / Token.cs
//----------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// Provides a type to represent a parsed token.
//
//
// @owner [....]
//---------------------------------------------------------------------
namespace System.Data.Services.Parsing
{
using System;
using System.Diagnostics;
/// Use this class to represent a lexical token.
[DebuggerDisplay("{Id} @ {Position}: [{Text}]")]
internal struct Token
{
/// Kind of token.
internal TokenId Id;
/// Token text.
internal string Text;
/// Position of token.
internal int Position;
/// Checks whether this token is a comparison operator.
internal bool IsComparisonOperator
{
get
{
if (this.Id != TokenId.Identifier)
{
return false;
}
return
this.Text == ExpressionConstants.KeywordEqual ||
this.Text == ExpressionConstants.KeywordNotEqual ||
this.Text == ExpressionConstants.KeywordLessThan ||
this.Text == ExpressionConstants.KeywordGreaterThan ||
this.Text == ExpressionConstants.KeywordLessThanOrEqual ||
this.Text == ExpressionConstants.KeywordGreaterThanOrEqual;
}
}
/// Checks whether this token is an equality operator.
internal bool IsEqualityOperator
{
get
{
return
this.Id == TokenId.Identifier &&
(this.Text == ExpressionConstants.KeywordEqual ||
this.Text == ExpressionConstants.KeywordNotEqual);
}
}
/// Checks whether this token is a valid token for a key value.
internal bool IsKeyValueToken
{
get
{
return
this.Id == TokenId.BinaryLiteral ||
this.Id == TokenId.BooleanLiteral ||
this.Id == TokenId.DateTimeLiteral ||
this.Id == TokenId.GuidLiteral ||
this.Id == TokenId.StringLiteral ||
ExpressionLexer.IsNumeric(this.Id);
}
}
/// Provides a string representation of this token.
/// String representation of this token.
public override string ToString()
{
return String.Format(System.Globalization.CultureInfo.InvariantCulture, "{0} @ {1}: [{2}]", this.Id, this.Position, this.Text);
}
/// Gets the current identifier text.
/// The current identifier text.
internal string GetIdentifier()
{
if (this.Id != TokenId.Identifier)
{
throw DataServiceException.CreateSyntaxError(Strings.RequestQueryParser_IdentifierExpected(this.Position));
}
return this.Text;
}
/// Checks that this token has the specified identifier.
/// Identifier to check.
/// true if this is an identifier with the specified text.
internal bool IdentifierIs(string id)
{
return this.Id == TokenId.Identifier && this.Text == id;
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
//----------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// Provides a type to represent a parsed token.
//
//
// @owner [....]
//---------------------------------------------------------------------
namespace System.Data.Services.Parsing
{
using System;
using System.Diagnostics;
/// Use this class to represent a lexical token.
[DebuggerDisplay("{Id} @ {Position}: [{Text}]")]
internal struct Token
{
/// Kind of token.
internal TokenId Id;
/// Token text.
internal string Text;
/// Position of token.
internal int Position;
/// Checks whether this token is a comparison operator.
internal bool IsComparisonOperator
{
get
{
if (this.Id != TokenId.Identifier)
{
return false;
}
return
this.Text == ExpressionConstants.KeywordEqual ||
this.Text == ExpressionConstants.KeywordNotEqual ||
this.Text == ExpressionConstants.KeywordLessThan ||
this.Text == ExpressionConstants.KeywordGreaterThan ||
this.Text == ExpressionConstants.KeywordLessThanOrEqual ||
this.Text == ExpressionConstants.KeywordGreaterThanOrEqual;
}
}
/// Checks whether this token is an equality operator.
internal bool IsEqualityOperator
{
get
{
return
this.Id == TokenId.Identifier &&
(this.Text == ExpressionConstants.KeywordEqual ||
this.Text == ExpressionConstants.KeywordNotEqual);
}
}
/// Checks whether this token is a valid token for a key value.
internal bool IsKeyValueToken
{
get
{
return
this.Id == TokenId.BinaryLiteral ||
this.Id == TokenId.BooleanLiteral ||
this.Id == TokenId.DateTimeLiteral ||
this.Id == TokenId.GuidLiteral ||
this.Id == TokenId.StringLiteral ||
ExpressionLexer.IsNumeric(this.Id);
}
}
/// Provides a string representation of this token.
/// String representation of this token.
public override string ToString()
{
return String.Format(System.Globalization.CultureInfo.InvariantCulture, "{0} @ {1}: [{2}]", this.Id, this.Position, this.Text);
}
/// Gets the current identifier text.
/// The current identifier text.
internal string GetIdentifier()
{
if (this.Id != TokenId.Identifier)
{
throw DataServiceException.CreateSyntaxError(Strings.RequestQueryParser_IdentifierExpected(this.Position));
}
return this.Text;
}
/// Checks that this token has the specified identifier.
/// Identifier to check.
/// true if this is an identifier with the specified text.
internal bool IdentifierIs(string id)
{
return this.Id == TokenId.Identifier && this.Text == id;
}
}
}
// 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
- TabletCollection.cs
- DataBinding.cs
- ServerTooBusyException.cs
- CustomError.cs
- FilteredDataSetHelper.cs
- SchemaNames.cs
- AsymmetricAlgorithm.cs
- ForceCopyBuildProvider.cs
- Automation.cs
- ReceiveErrorHandling.cs
- PlatformNotSupportedException.cs
- controlskin.cs
- BroadcastEventHelper.cs
- ToolStripDesignerAvailabilityAttribute.cs
- SqlTriggerContext.cs
- DependencyPropertyDescriptor.cs
- Attributes.cs
- SiteMapDataSource.cs
- XmlQueryCardinality.cs
- InternalControlCollection.cs
- TypedElement.cs
- CellIdBoolean.cs
- DateTimeConverter2.cs
- SafeNativeMethods.cs
- HttpWebRequest.cs
- MissingMemberException.cs
- RunClient.cs
- SessionIDManager.cs
- SortedSetDebugView.cs
- WebPartConnectionsConnectVerb.cs
- DataGridViewIntLinkedList.cs
- ISO2022Encoding.cs
- XmlSchemaObjectCollection.cs
- PrintController.cs
- DataPagerFieldCommandEventArgs.cs
- DesignerActionService.cs
- OutputCacheProfileCollection.cs
- Quaternion.cs
- ImageEditor.cs
- AdCreatedEventArgs.cs
- ChannelSinkStacks.cs
- CategoryGridEntry.cs
- ImageMapEventArgs.cs
- ProcessModuleCollection.cs
- PagerSettings.cs
- ChtmlCalendarAdapter.cs
- DataGrid.cs
- HandledEventArgs.cs
- GridViewEditEventArgs.cs
- RoutedEventConverter.cs
- Formatter.cs
- BulletedList.cs
- SiteMapHierarchicalDataSourceView.cs
- StaticExtensionConverter.cs
- LineBreak.cs
- Update.cs
- CompressionTransform.cs
- FileAuthorizationModule.cs
- xml.cs
- XomlCompilerHelpers.cs
- XmlSchemas.cs
- RemoteWebConfigurationHostServer.cs
- RangeBase.cs
- FileRecordSequenceCompletedAsyncResult.cs
- DataGridBoolColumn.cs
- keycontainerpermission.cs
- EntityDataSourceEntitySetNameItem.cs
- ProcessThreadCollection.cs
- BitmapFrameEncode.cs
- InlineObject.cs
- Html32TextWriter.cs
- ToolBar.cs
- Missing.cs
- ADMembershipProvider.cs
- ContentType.cs
- DrawItemEvent.cs
- EventManager.cs
- SignedXml.cs
- _StreamFramer.cs
- PersonalizationDictionary.cs
- RestHandlerFactory.cs
- Clipboard.cs
- SmtpCommands.cs
- UpdateProgress.cs
- CodeConditionStatement.cs
- ParallelEnumerableWrapper.cs
- WebPartRestoreVerb.cs
- VolatileResourceManager.cs
- TableItemProviderWrapper.cs
- SynchronizationLockException.cs
- XmlCharCheckingReader.cs
- WizardStepBase.cs
- initElementDictionary.cs
- FixedSchema.cs
- KnownTypes.cs
- MemberAssignment.cs
- XPathDocumentIterator.cs
- ExceptionUtil.cs
- DeclarativeCatalogPart.cs
- ForeignConstraint.cs