Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / whidbey / NetFXspW7 / ndp / fx / src / Data / System / Data / Filter / NameNode.cs / 1 / NameNode.cs
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// [....]
// [....]
// [....]
//-----------------------------------------------------------------------------
namespace System.Data {
using System;
using System.ComponentModel;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
internal sealed class NameNode : ExpressionNode {
internal char open = '\0';
internal char close = '\0';
internal string name;
internal bool found;
internal bool type = false;
internal DataColumn column;
internal NameNode(DataTable table, char[] text, int start, int pos) : base(table) {
this.name = ParseName(text, start, pos);
}
internal NameNode(DataTable table, string name) : base(table) {
this.name = name;
}
internal override bool IsSqlColumn{
get{
return column.IsSqlType;
}
}
internal override void Bind(DataTable table, List list) {
BindTable(table);
if (table == null)
throw ExprException.UnboundName(name);
try {
this.column = table.Columns[name];
}
catch (Exception e) {
found = false;
//
if (!Common.ADP.IsCatchableExceptionType(e)) {
throw;
}
throw ExprException.UnboundName(name);
}
if (column == null)
throw ExprException.UnboundName(name);
name = column.ColumnName;
found = true;
// add column to the dependency list, do not add duplicate columns
Debug.Assert(column != null, "Failed to bind column " + name);
int i;
for (i = 0; i < list.Count; i++) {
// walk the list, check if the current column already on the list
DataColumn dataColumn = list[i];
if (column == dataColumn) {
break;
}
}
if (i >= list.Count) {
list.Add(column);
}
}
internal override object Eval() {
// can not eval column without ROW value;
throw ExprException.EvalNoContext();
}
internal override object Eval(DataRow row, DataRowVersion version) {
if (!found) {
throw ExprException.UnboundName(name);
}
if (row == null) {
if(IsTableConstant()) // this column is TableConstant Aggregate Function
return column.DataExpression.Evaluate();
else {
throw ExprException.UnboundName(name);
}
}
return column[row.GetRecordFromVersion(version)];
}
internal override object Eval(int[] records) {
throw ExprException.ComputeNotAggregate(this.ToString());
}
internal override bool IsConstant() {
return false;
}
internal override bool IsTableConstant() {
if (column != null && column.Computed) {
return this.column.DataExpression.IsTableAggregate();
}
return false;
}
internal override bool HasLocalAggregate() {
if (column != null && column.Computed) {
return this.column.DataExpression.HasLocalAggregate();
}
return false;
}
internal override bool HasRemoteAggregate() {
if (column != null && column.Computed) {
return this.column.DataExpression.HasRemoteAggregate();
}
return false;
}
internal override bool DependsOn(DataColumn column) {
if (this.column == column)
return true;
if (this.column.Computed) {
return this.column.DataExpression.DependsOn(column);
}
return false;
}
internal override ExpressionNode Optimize() {
return this;
}
///
/// Parses given name and checks it validity
///
internal static string ParseName(char[] text, int start, int pos) {
char esc = '\0';
string charsToEscape = "";
int saveStart = start;
int savePos = pos;
if (text[start] == '`') {
Debug.Assert(text[checked((int)pos-1)] == '`', "Invalid identifyer bracketing, pos = " + pos.ToString(CultureInfo.InvariantCulture) + ", end = " + text[checked((int)pos-1)].ToString(CultureInfo.InvariantCulture));
start = checked((int)start+1);
pos = checked((int)pos-1);
esc = '\\';
charsToEscape = "`";
}
else if (text[start] == '[') {
Debug.Assert(text[checked((int)pos-1)] == ']', "Invalid identifyer bracketing of name " + new string(text, start, pos-start) + " pos = " + pos.ToString(CultureInfo.InvariantCulture) + ", end = " + text[checked((int)pos-1)].ToString(CultureInfo.InvariantCulture));
start = checked((int)start+1);
pos = checked((int)pos-1);
esc = '\\';
charsToEscape = "]\\";
}
if (esc != '\0') {
// scan the name in search for the ESC
int posEcho = start;
for (int i = start; i < pos; i++) {
if (text[i] == esc) {
if (i+1 < pos && charsToEscape.IndexOf(text[i+1]) >= 0) {
i++;
}
}
text[posEcho] = text[i];
posEcho++;
}
pos = posEcho;
}
if (pos == start)
throw ExprException.InvalidName(new string(text, saveStart, savePos - saveStart));
return new string(text, start, pos - start);
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// [....]
// [....]
// [....]
//-----------------------------------------------------------------------------
namespace System.Data {
using System;
using System.ComponentModel;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
internal sealed class NameNode : ExpressionNode {
internal char open = '\0';
internal char close = '\0';
internal string name;
internal bool found;
internal bool type = false;
internal DataColumn column;
internal NameNode(DataTable table, char[] text, int start, int pos) : base(table) {
this.name = ParseName(text, start, pos);
}
internal NameNode(DataTable table, string name) : base(table) {
this.name = name;
}
internal override bool IsSqlColumn{
get{
return column.IsSqlType;
}
}
internal override void Bind(DataTable table, List list) {
BindTable(table);
if (table == null)
throw ExprException.UnboundName(name);
try {
this.column = table.Columns[name];
}
catch (Exception e) {
found = false;
//
if (!Common.ADP.IsCatchableExceptionType(e)) {
throw;
}
throw ExprException.UnboundName(name);
}
if (column == null)
throw ExprException.UnboundName(name);
name = column.ColumnName;
found = true;
// add column to the dependency list, do not add duplicate columns
Debug.Assert(column != null, "Failed to bind column " + name);
int i;
for (i = 0; i < list.Count; i++) {
// walk the list, check if the current column already on the list
DataColumn dataColumn = list[i];
if (column == dataColumn) {
break;
}
}
if (i >= list.Count) {
list.Add(column);
}
}
internal override object Eval() {
// can not eval column without ROW value;
throw ExprException.EvalNoContext();
}
internal override object Eval(DataRow row, DataRowVersion version) {
if (!found) {
throw ExprException.UnboundName(name);
}
if (row == null) {
if(IsTableConstant()) // this column is TableConstant Aggregate Function
return column.DataExpression.Evaluate();
else {
throw ExprException.UnboundName(name);
}
}
return column[row.GetRecordFromVersion(version)];
}
internal override object Eval(int[] records) {
throw ExprException.ComputeNotAggregate(this.ToString());
}
internal override bool IsConstant() {
return false;
}
internal override bool IsTableConstant() {
if (column != null && column.Computed) {
return this.column.DataExpression.IsTableAggregate();
}
return false;
}
internal override bool HasLocalAggregate() {
if (column != null && column.Computed) {
return this.column.DataExpression.HasLocalAggregate();
}
return false;
}
internal override bool HasRemoteAggregate() {
if (column != null && column.Computed) {
return this.column.DataExpression.HasRemoteAggregate();
}
return false;
}
internal override bool DependsOn(DataColumn column) {
if (this.column == column)
return true;
if (this.column.Computed) {
return this.column.DataExpression.DependsOn(column);
}
return false;
}
internal override ExpressionNode Optimize() {
return this;
}
///
/// Parses given name and checks it validity
///
internal static string ParseName(char[] text, int start, int pos) {
char esc = '\0';
string charsToEscape = "";
int saveStart = start;
int savePos = pos;
if (text[start] == '`') {
Debug.Assert(text[checked((int)pos-1)] == '`', "Invalid identifyer bracketing, pos = " + pos.ToString(CultureInfo.InvariantCulture) + ", end = " + text[checked((int)pos-1)].ToString(CultureInfo.InvariantCulture));
start = checked((int)start+1);
pos = checked((int)pos-1);
esc = '\\';
charsToEscape = "`";
}
else if (text[start] == '[') {
Debug.Assert(text[checked((int)pos-1)] == ']', "Invalid identifyer bracketing of name " + new string(text, start, pos-start) + " pos = " + pos.ToString(CultureInfo.InvariantCulture) + ", end = " + text[checked((int)pos-1)].ToString(CultureInfo.InvariantCulture));
start = checked((int)start+1);
pos = checked((int)pos-1);
esc = '\\';
charsToEscape = "]\\";
}
if (esc != '\0') {
// scan the name in search for the ESC
int posEcho = start;
for (int i = start; i < pos; i++) {
if (text[i] == esc) {
if (i+1 < pos && charsToEscape.IndexOf(text[i+1]) >= 0) {
i++;
}
}
text[posEcho] = text[i];
posEcho++;
}
pos = posEcho;
}
if (pos == start)
throw ExprException.InvalidName(new string(text, saveStart, savePos - saveStart));
return new string(text, start, pos - start);
}
}
}
// 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
- EqualityArray.cs
- Environment.cs
- DataGridViewRowsAddedEventArgs.cs
- DetailsViewDesigner.cs
- SecurityHelper.cs
- XmlSchemaExternal.cs
- ExceptionRoutedEventArgs.cs
- PackageRelationshipCollection.cs
- basevalidator.cs
- XmlAnyAttributeAttribute.cs
- ExceptionRoutedEventArgs.cs
- CoreSwitches.cs
- StickyNoteContentControl.cs
- FixedHyperLink.cs
- CredentialCache.cs
- wmiprovider.cs
- ControlParser.cs
- TemplatePartAttribute.cs
- WindowsGraphicsWrapper.cs
- XmlSchemaObjectCollection.cs
- TreeViewEvent.cs
- AssemblyAssociatedContentFileAttribute.cs
- RC2CryptoServiceProvider.cs
- RoleGroupCollectionEditor.cs
- MostlySingletonList.cs
- PathFigureCollection.cs
- ExecutionContext.cs
- RightNameExpirationInfoPair.cs
- SynchronizingStream.cs
- TextTreeUndo.cs
- LabelLiteral.cs
- WebConfigurationHostFileChange.cs
- _RequestCacheProtocol.cs
- UnrecognizedAssertionsBindingElement.cs
- NullEntityWrapper.cs
- TypedDatasetGenerator.cs
- KerberosTicketHashIdentifierClause.cs
- arabicshape.cs
- XmlSchemaGroup.cs
- RecommendedAsConfigurableAttribute.cs
- SkipStoryboardToFill.cs
- StaticFileHandler.cs
- MenuItemStyleCollection.cs
- FilterQueryOptionExpression.cs
- StringValidatorAttribute.cs
- PackWebRequestFactory.cs
- Variant.cs
- DESCryptoServiceProvider.cs
- RepeatBehavior.cs
- ColorAnimationBase.cs
- TypeViewSchema.cs
- typedescriptorpermissionattribute.cs
- WorkflowControlEndpoint.cs
- EventManager.cs
- XPathSelfQuery.cs
- SetterBaseCollection.cs
- HtmlControlPersistable.cs
- PeerPresenceInfo.cs
- DynamicILGenerator.cs
- HttpUnhandledOperationInvoker.cs
- RtfControlWordInfo.cs
- BitmapPalettes.cs
- PolicyException.cs
- GlobalizationSection.cs
- RijndaelManaged.cs
- SocketInformation.cs
- WindowsFormsHostPropertyMap.cs
- StrokeRenderer.cs
- ByteStreamMessageEncoder.cs
- GuidelineSet.cs
- MobileControlsSectionHelper.cs
- SqlDeflator.cs
- ParallelLoopState.cs
- ResourcePermissionBaseEntry.cs
- ColorBlend.cs
- XdrBuilder.cs
- BrowserCapabilitiesCompiler.cs
- NodeInfo.cs
- RowToParametersTransformer.cs
- HostProtectionPermission.cs
- SmtpCommands.cs
- ErrorProvider.cs
- ProjectionCamera.cs
- SecureConversationDriver.cs
- InheritanceService.cs
- TypeConstant.cs
- MasterPage.cs
- RequestQueue.cs
- SimpleType.cs
- GiveFeedbackEvent.cs
- _Connection.cs
- ExpressionBindingCollection.cs
- MimePart.cs
- WindowVisualStateTracker.cs
- ConfigXmlWhitespace.cs
- MessageVersionConverter.cs
- WinCategoryAttribute.cs
- KeyValueInternalCollection.cs
- SortQuery.cs
- DirectionalLight.cs