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 / Query / PlanCompiler / VarInfo.cs / 1 / VarInfo.cs
//----------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// @owner [....], [....]
//---------------------------------------------------------------------
using System;
using System.Collections.Generic;
//using System.Diagnostics; // Please use PlanCompiler.Assert instead of Debug.Assert in this class...
using System.Globalization;
using System.Data.Common;
using md = System.Data.Metadata.Edm;
using System.Data.Query.InternalTrees;
using System.Data.Query.PlanCompiler;
namespace System.Data.Query.PlanCompiler {
///
/// Information about a Var and its replacement
///
internal abstract class VarInfo {
///
/// Does this VarInfo represent a structured type
///
internal virtual bool IsStructuredType { get { return false; } }
///
/// Does this VarInfo represent a collection type
///
internal virtual bool IsCollectionType { get { return false; } }
///
/// Get the list of new Vars introduced by this VarInfo
///
internal virtual List NewVars { get { return null; } }
}
///
/// Represents information about a collection typed Var.
/// Each such Var is replaced by a Var with a new "mapped" type - the "mapped" type
/// is simply a collection type where the element type has been "mapped"
///
internal class CollectionVarInfo : VarInfo {
private List m_newVars; // always a singleton list
///
/// Create a CollectionVarInfo
///
///
internal CollectionVarInfo(Var newVar) {
m_newVars = new List();
m_newVars.Add(newVar);
}
///
/// Get the newVar
///
internal Var NewVar { get { return m_newVars[0]; } }
///
/// This is for a collection-type Var
///
internal override bool IsCollectionType { get { return true; } }
///
/// Get the list of all NewVars - just one really
///
internal override List NewVars { get { return m_newVars; } }
}
///
/// The StructuredVarInfo class contains information about a structured type Var
/// and how it can be replaced. This is targeted towards Vars of complex/record/
/// entity/ref types, and the goal is to replace all such Vars in this module.
///
internal class StructuredVarInfo : VarInfo {
private Dictionary m_propertyToVarMap;
List m_newVars;
List m_newProperties;
md.RowType m_newType;
md.TypeUsage m_newTypeUsage;
///
/// Constructor
///
/// new "flat" record type corresponding to the Var's datatype
/// List of vars to replace current Var
/// List of properties in the "flat" record type
internal StructuredVarInfo(md.RowType newType, List newVars, List newTypeProperties) {
PlanCompiler.Assert(newVars.Count == newTypeProperties.Count, "count mismatch");
// I see a few places where this is legal
// PlanCompiler.Assert(newVars.Count > 0, "0 vars?");
m_newVars = newVars;
m_newProperties = newTypeProperties;
m_newType = newType;
m_newTypeUsage = md.TypeUsage.Create(newType);
}
///
/// This VarInfo represents a structured type
///
internal override bool IsStructuredType { get { return true; } }
///
/// The NewVars property of the VarInfo is a list of the corresponding
/// "scalar" Vars that can be used to replace the current Var. This is
/// mainly intended for use by other RelOps that maintain lists of Vars
/// - for example, the "Vars" property of ProjectOp and other similar
/// locations.
///
internal override List NewVars { get { return m_newVars; } }
///
/// The Fields property is matched 1-1 with the NewVars property, and
/// specifies the properties of the record type corresponding to the
/// original VarType
///
internal List Fields { get { return m_newProperties; } }
///
/// Get the Var corresponding to a specific property
///
/// the requested property
/// the corresponding Var
/// true, if the Var was found
internal bool TryGetVar(md.EdmProperty p, out Var v) {
if (m_propertyToVarMap == null) {
InitPropertyToVarMap();
}
return m_propertyToVarMap.TryGetValue(p, out v);
}
///
/// The NewType property describes the new "flattened" record type
/// that is a replacement for the original type of the Var
///
internal md.RowType NewType { get { return m_newType; } }
///
/// Returns the NewType wrapped in a TypeUsage
///
internal md.TypeUsage NewTypeUsage { get { return m_newTypeUsage; } }
///
/// Initialize mapping from properties to the corresponding Var
///
private void InitPropertyToVarMap() {
if (m_propertyToVarMap == null) {
m_propertyToVarMap = new Dictionary();
IEnumerator newVarEnumerator = m_newVars.GetEnumerator();
foreach (md.EdmProperty prop in m_newProperties) {
newVarEnumerator.MoveNext();
m_propertyToVarMap.Add(prop, newVarEnumerator.Current);
}
newVarEnumerator.Dispose();
}
}
}
///
/// The VarInfo map maintains a mapping from Vars to their corresponding VarInfo
/// It is logically a Dictionary
///
internal class VarInfoMap {
private Dictionary m_map;
///
/// Default constructor
///
internal VarInfoMap() {
m_map = new Dictionary();
}
///
/// Create a new VarInfo for a structured type Var
///
/// The structured type Var
/// "Mapped" type for v
/// List of vars corresponding to v
/// Flattened Properties
/// the VarInfo
internal VarInfo CreateStructuredVarInfo(Var v, md.RowType newType, List newVars, List newProperties) {
VarInfo varInfo = new StructuredVarInfo(newType, newVars, newProperties);
m_map.Add(v, varInfo);
return varInfo;
}
///
/// Create a VarInfo for a collection typed Var
///
/// The collection-typed Var
/// the new Var
/// the VarInfo
internal VarInfo CreateCollectionVarInfo(Var v, Var newVar) {
VarInfo varInfo = new CollectionVarInfo(newVar);
m_map.Add(v, varInfo);
return varInfo;
}
///
/// Return the VarInfo for the specified var (if one exists, of course)
///
/// The Var
/// the corresponding VarInfo
///
internal bool TryGetVarInfo(Var v, out VarInfo varInfo) {
return m_map.TryGetValue(v, out varInfo);
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
//----------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// @owner [....], [....]
//---------------------------------------------------------------------
using System;
using System.Collections.Generic;
//using System.Diagnostics; // Please use PlanCompiler.Assert instead of Debug.Assert in this class...
using System.Globalization;
using System.Data.Common;
using md = System.Data.Metadata.Edm;
using System.Data.Query.InternalTrees;
using System.Data.Query.PlanCompiler;
namespace System.Data.Query.PlanCompiler {
///
/// Information about a Var and its replacement
///
internal abstract class VarInfo {
///
/// Does this VarInfo represent a structured type
///
internal virtual bool IsStructuredType { get { return false; } }
///
/// Does this VarInfo represent a collection type
///
internal virtual bool IsCollectionType { get { return false; } }
///
/// Get the list of new Vars introduced by this VarInfo
///
internal virtual List NewVars { get { return null; } }
}
///
/// Represents information about a collection typed Var.
/// Each such Var is replaced by a Var with a new "mapped" type - the "mapped" type
/// is simply a collection type where the element type has been "mapped"
///
internal class CollectionVarInfo : VarInfo {
private List m_newVars; // always a singleton list
///
/// Create a CollectionVarInfo
///
///
internal CollectionVarInfo(Var newVar) {
m_newVars = new List();
m_newVars.Add(newVar);
}
///
/// Get the newVar
///
internal Var NewVar { get { return m_newVars[0]; } }
///
/// This is for a collection-type Var
///
internal override bool IsCollectionType { get { return true; } }
///
/// Get the list of all NewVars - just one really
///
internal override List NewVars { get { return m_newVars; } }
}
///
/// The StructuredVarInfo class contains information about a structured type Var
/// and how it can be replaced. This is targeted towards Vars of complex/record/
/// entity/ref types, and the goal is to replace all such Vars in this module.
///
internal class StructuredVarInfo : VarInfo {
private Dictionary m_propertyToVarMap;
List m_newVars;
List m_newProperties;
md.RowType m_newType;
md.TypeUsage m_newTypeUsage;
///
/// Constructor
///
/// new "flat" record type corresponding to the Var's datatype
/// List of vars to replace current Var
/// List of properties in the "flat" record type
internal StructuredVarInfo(md.RowType newType, List newVars, List newTypeProperties) {
PlanCompiler.Assert(newVars.Count == newTypeProperties.Count, "count mismatch");
// I see a few places where this is legal
// PlanCompiler.Assert(newVars.Count > 0, "0 vars?");
m_newVars = newVars;
m_newProperties = newTypeProperties;
m_newType = newType;
m_newTypeUsage = md.TypeUsage.Create(newType);
}
///
/// This VarInfo represents a structured type
///
internal override bool IsStructuredType { get { return true; } }
///
/// The NewVars property of the VarInfo is a list of the corresponding
/// "scalar" Vars that can be used to replace the current Var. This is
/// mainly intended for use by other RelOps that maintain lists of Vars
/// - for example, the "Vars" property of ProjectOp and other similar
/// locations.
///
internal override List NewVars { get { return m_newVars; } }
///
/// The Fields property is matched 1-1 with the NewVars property, and
/// specifies the properties of the record type corresponding to the
/// original VarType
///
internal List Fields { get { return m_newProperties; } }
///
/// Get the Var corresponding to a specific property
///
/// the requested property
/// the corresponding Var
/// true, if the Var was found
internal bool TryGetVar(md.EdmProperty p, out Var v) {
if (m_propertyToVarMap == null) {
InitPropertyToVarMap();
}
return m_propertyToVarMap.TryGetValue(p, out v);
}
///
/// The NewType property describes the new "flattened" record type
/// that is a replacement for the original type of the Var
///
internal md.RowType NewType { get { return m_newType; } }
///
/// Returns the NewType wrapped in a TypeUsage
///
internal md.TypeUsage NewTypeUsage { get { return m_newTypeUsage; } }
///
/// Initialize mapping from properties to the corresponding Var
///
private void InitPropertyToVarMap() {
if (m_propertyToVarMap == null) {
m_propertyToVarMap = new Dictionary();
IEnumerator newVarEnumerator = m_newVars.GetEnumerator();
foreach (md.EdmProperty prop in m_newProperties) {
newVarEnumerator.MoveNext();
m_propertyToVarMap.Add(prop, newVarEnumerator.Current);
}
newVarEnumerator.Dispose();
}
}
}
///
/// The VarInfo map maintains a mapping from Vars to their corresponding VarInfo
/// It is logically a Dictionary
///
internal class VarInfoMap {
private Dictionary m_map;
///
/// Default constructor
///
internal VarInfoMap() {
m_map = new Dictionary();
}
///
/// Create a new VarInfo for a structured type Var
///
/// The structured type Var
/// "Mapped" type for v
/// List of vars corresponding to v
/// Flattened Properties
/// the VarInfo
internal VarInfo CreateStructuredVarInfo(Var v, md.RowType newType, List newVars, List newProperties) {
VarInfo varInfo = new StructuredVarInfo(newType, newVars, newProperties);
m_map.Add(v, varInfo);
return varInfo;
}
///
/// Create a VarInfo for a collection typed Var
///
/// The collection-typed Var
/// the new Var
/// the VarInfo
internal VarInfo CreateCollectionVarInfo(Var v, Var newVar) {
VarInfo varInfo = new CollectionVarInfo(newVar);
m_map.Add(v, varInfo);
return varInfo;
}
///
/// Return the VarInfo for the specified var (if one exists, of course)
///
/// The Var
/// the corresponding VarInfo
///
internal bool TryGetVarInfo(Var v, out VarInfo varInfo) {
return m_map.TryGetValue(v, out varInfo);
}
}
}
// 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
- XhtmlBasicTextBoxAdapter.cs
- FixedHighlight.cs
- SetterBaseCollection.cs
- FontInfo.cs
- ToolStripRenderEventArgs.cs
- TimeSpanValidatorAttribute.cs
- LayoutTable.cs
- EntityObject.cs
- DropShadowEffect.cs
- MessageBox.cs
- EntityWrapperFactory.cs
- OpenFileDialog.cs
- QilExpression.cs
- ColorMatrix.cs
- RayMeshGeometry3DHitTestResult.cs
- XmlSchemaSimpleType.cs
- OpCodes.cs
- WebDisplayNameAttribute.cs
- OutOfProcStateClientManager.cs
- TogglePattern.cs
- AttachedAnnotationChangedEventArgs.cs
- Literal.cs
- TimerElapsedEvenArgs.cs
- IList.cs
- RegexInterpreter.cs
- NegotiationTokenProvider.cs
- ServiceMemoryGates.cs
- XamlWriter.cs
- ParameterToken.cs
- Lease.cs
- SlotInfo.cs
- PrePostDescendentsWalker.cs
- EpmCustomContentSerializer.cs
- RuntimeConfig.cs
- IConvertible.cs
- AssociatedControlConverter.cs
- DataServiceRequestException.cs
- _NegoState.cs
- WindowInteractionStateTracker.cs
- ReturnValue.cs
- ScrollBarAutomationPeer.cs
- SelectionWordBreaker.cs
- Vector3DConverter.cs
- ResourceIDHelper.cs
- NativeCompoundFileAPIs.cs
- DrawToolTipEventArgs.cs
- EntityClientCacheKey.cs
- HashStream.cs
- SpellerHighlightLayer.cs
- StylusShape.cs
- XmlNodeReader.cs
- ValidatorCollection.cs
- DoubleAnimationUsingKeyFrames.cs
- ConnectionStringsExpressionBuilder.cs
- KoreanLunisolarCalendar.cs
- Crc32Helper.cs
- Ipv6Element.cs
- baseaxisquery.cs
- SecureStringHasher.cs
- CompilerErrorCollection.cs
- DecoderExceptionFallback.cs
- SqlConnectionStringBuilder.cs
- DbCommandTree.cs
- ColorConverter.cs
- StopStoryboard.cs
- QueryContinueDragEventArgs.cs
- StateWorkerRequest.cs
- DetailsViewPagerRow.cs
- SqlRemoveConstantOrderBy.cs
- HostingEnvironment.cs
- SignatureGenerator.cs
- ViewValidator.cs
- SmtpDigestAuthenticationModule.cs
- CultureSpecificCharacterBufferRange.cs
- XmlAttributes.cs
- WindowsGraphicsCacheManager.cs
- EntityCommandDefinition.cs
- AudioBase.cs
- ZipIOExtraFieldPaddingElement.cs
- ErrorTableItemStyle.cs
- DateTimeValueSerializer.cs
- HtmlShimManager.cs
- EntityDataSourceContextCreatedEventArgs.cs
- DeviceContext2.cs
- WebPartZone.cs
- HttpCapabilitiesBase.cs
- ForeignKeyConstraint.cs
- IFlowDocumentViewer.cs
- PropertyInfo.cs
- UnhandledExceptionEventArgs.cs
- DiagnosticTrace.cs
- FontFamilyConverter.cs
- BCLDebug.cs
- CodeSnippetTypeMember.cs
- TextWriter.cs
- SocketException.cs
- UserNamePasswordValidator.cs
- TypeInitializationException.cs
- ResourcePermissionBase.cs
- AddInEnvironment.cs