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 / Map / ViewGeneration / CqlGeneration / CaseCqlBlock.cs / 1 / CaseCqlBlock.cs
//----------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// @owner [....]
// @backupOwner [....]
//---------------------------------------------------------------------
using System.Data.Mapping.ViewGeneration.Structures;
using System.Text;
using System.Collections.Generic;
using System.Data.Common.Utils;
using System.Diagnostics;
namespace System.Data.Mapping.ViewGeneration.CqlGeneration {
// A class to capture CqlBlocks responsible for case statements -- these
// are statements needed for generating the variables in the
// multiconstants, i.e., complex types, entities, discriminators, etc
internal class CaseCqlBlock : CqlBlock {
#region Constructors
// effects: Creates a case statememt CqlBlock with SELECT (slots),
// FROM (child -- note has only has one child), WHERE (true), AS
// (blockAliasNum). caseSlot indicates which slot in slots
// corresponds to the single case statement being generated by this block
internal CaseCqlBlock(SlotInfo[] slots, int caseSlot, CqlBlock child, BoolExpression whereClause, CqlIdentifiers identifiers, int blockAliasNum) :
base(slots, new List(new CqlBlock[]{child}), whereClause, identifiers, blockAliasNum) {
m_caseSlotInfo = slots[caseSlot];
}
#endregion
#region Fields
private SlotInfo m_caseSlotInfo;
#endregion
#region Methods
// effects: See CqlBlock.AsCql
internal override StringBuilder AsCql(StringBuilder builder, bool isTopLevel, int indentLevel) {
// The SELECT part
StringUtil.IndentNewLine(builder, indentLevel);
// Since we know that the case statement starts on a new line, we
// can add a comment after SELECT
Debug.Assert(m_caseSlotInfo.MemberPath != null, "We only construct real slots not boolean slots");
builder.Append("SELECT ");
if (isTopLevel) {
builder.Append("VALUE ");
}
builder.Append("-- Constructing ")
.Append(m_caseSlotInfo.MemberPath.LastComponentName);
Debug.Assert(Children.Count == 1, "Case can have exactly one child");
CqlBlock childBlock = Children[0];
// First emit the case statement "CASE ... END AS Alias"
m_caseSlotInfo.AsCql(builder, childBlock.CqlAlias, indentLevel);
if (false == isTopLevel) {
builder.Append(" AS ")
.Append(m_caseSlotInfo.CqlFieldAlias);
}
// Now get the remaining slots
bool isFirst = true;
// CHANGE_[....]_IMPROVE: Try to leverage GenerateProjectedtList
foreach (SlotInfo slot in Slots) {
if (false == slot.IsRequiredByParent || object.ReferenceEquals(slot, m_caseSlotInfo)) {
continue;
}
if (isFirst == true) {
// Add , after END and then start new line for first field
builder.Append(", ");
StringUtil.IndentNewLine(builder, indentLevel + 1);
} else {
// Simply add a comma for the next field
builder.Append(", ");
}
slot.AsCql(builder, childBlock.CqlAlias, indentLevel);
isFirst = false;
}
// The FROM part: FROM (ChildView) AS AliasName
StringUtil.IndentNewLine(builder, indentLevel);
builder.Append("FROM (");
// Get the child
childBlock.AsCql(builder, false, indentLevel + 1);
StringUtil.IndentNewLine(builder, indentLevel);
builder.Append(") AS ")
.Append(childBlock.CqlAlias);
// Get the WHERE part only when the expression is not simply TRUE
if (false == BoolExpression.EqualityComparer.Equals(WhereClause, BoolExpression.True)) {
StringUtil.IndentNewLine(builder, indentLevel);
builder.Append("WHERE ");
WhereClause.AsCql(builder, childBlock.CqlAlias);
}
return builder;
}
#endregion
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
//----------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// @owner [....]
// @backupOwner [....]
//---------------------------------------------------------------------
using System.Data.Mapping.ViewGeneration.Structures;
using System.Text;
using System.Collections.Generic;
using System.Data.Common.Utils;
using System.Diagnostics;
namespace System.Data.Mapping.ViewGeneration.CqlGeneration {
// A class to capture CqlBlocks responsible for case statements -- these
// are statements needed for generating the variables in the
// multiconstants, i.e., complex types, entities, discriminators, etc
internal class CaseCqlBlock : CqlBlock {
#region Constructors
// effects: Creates a case statememt CqlBlock with SELECT (slots),
// FROM (child -- note has only has one child), WHERE (true), AS
// (blockAliasNum). caseSlot indicates which slot in slots
// corresponds to the single case statement being generated by this block
internal CaseCqlBlock(SlotInfo[] slots, int caseSlot, CqlBlock child, BoolExpression whereClause, CqlIdentifiers identifiers, int blockAliasNum) :
base(slots, new List(new CqlBlock[]{child}), whereClause, identifiers, blockAliasNum) {
m_caseSlotInfo = slots[caseSlot];
}
#endregion
#region Fields
private SlotInfo m_caseSlotInfo;
#endregion
#region Methods
// effects: See CqlBlock.AsCql
internal override StringBuilder AsCql(StringBuilder builder, bool isTopLevel, int indentLevel) {
// The SELECT part
StringUtil.IndentNewLine(builder, indentLevel);
// Since we know that the case statement starts on a new line, we
// can add a comment after SELECT
Debug.Assert(m_caseSlotInfo.MemberPath != null, "We only construct real slots not boolean slots");
builder.Append("SELECT ");
if (isTopLevel) {
builder.Append("VALUE ");
}
builder.Append("-- Constructing ")
.Append(m_caseSlotInfo.MemberPath.LastComponentName);
Debug.Assert(Children.Count == 1, "Case can have exactly one child");
CqlBlock childBlock = Children[0];
// First emit the case statement "CASE ... END AS Alias"
m_caseSlotInfo.AsCql(builder, childBlock.CqlAlias, indentLevel);
if (false == isTopLevel) {
builder.Append(" AS ")
.Append(m_caseSlotInfo.CqlFieldAlias);
}
// Now get the remaining slots
bool isFirst = true;
// CHANGE_[....]_IMPROVE: Try to leverage GenerateProjectedtList
foreach (SlotInfo slot in Slots) {
if (false == slot.IsRequiredByParent || object.ReferenceEquals(slot, m_caseSlotInfo)) {
continue;
}
if (isFirst == true) {
// Add , after END and then start new line for first field
builder.Append(", ");
StringUtil.IndentNewLine(builder, indentLevel + 1);
} else {
// Simply add a comma for the next field
builder.Append(", ");
}
slot.AsCql(builder, childBlock.CqlAlias, indentLevel);
isFirst = false;
}
// The FROM part: FROM (ChildView) AS AliasName
StringUtil.IndentNewLine(builder, indentLevel);
builder.Append("FROM (");
// Get the child
childBlock.AsCql(builder, false, indentLevel + 1);
StringUtil.IndentNewLine(builder, indentLevel);
builder.Append(") AS ")
.Append(childBlock.CqlAlias);
// Get the WHERE part only when the expression is not simply TRUE
if (false == BoolExpression.EqualityComparer.Equals(WhereClause, BoolExpression.True)) {
StringUtil.IndentNewLine(builder, indentLevel);
builder.Append("WHERE ");
WhereClause.AsCql(builder, childBlock.CqlAlias);
}
return builder;
}
#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
- QueryContinueDragEvent.cs
- SafeReversePInvokeHandle.cs
- COMException.cs
- SSmlParser.cs
- CatalogPartCollection.cs
- ScrollableControl.cs
- RegexGroup.cs
- SemaphoreFullException.cs
- printdlgexmarshaler.cs
- WebPartPersonalization.cs
- DatagridviewDisplayedBandsData.cs
- MultiSelectRootGridEntry.cs
- TypeListConverter.cs
- Mapping.cs
- TransformedBitmap.cs
- DesignerSerializationOptionsAttribute.cs
- RepeatButton.cs
- ConditionalAttribute.cs
- PositiveTimeSpanValidator.cs
- CodeTypeDeclaration.cs
- TextCompositionManager.cs
- DataGridViewDataErrorEventArgs.cs
- MultipartIdentifier.cs
- CaseInsensitiveComparer.cs
- LinkButton.cs
- PhysicalFontFamily.cs
- WebPartVerb.cs
- LogFlushAsyncResult.cs
- CacheHelper.cs
- HiddenFieldPageStatePersister.cs
- SqlTopReducer.cs
- OuterGlowBitmapEffect.cs
- ChildrenQuery.cs
- DesignerVerbCollection.cs
- TypeAccessException.cs
- Trace.cs
- XPathQilFactory.cs
- Executor.cs
- SerTrace.cs
- ScrollViewerAutomationPeer.cs
- SiteMembershipCondition.cs
- OracleInfoMessageEventArgs.cs
- CustomErrorCollection.cs
- DataServiceEntityAttribute.cs
- TraceUtils.cs
- TypeInitializationException.cs
- LinkUtilities.cs
- WindowsRichEditRange.cs
- DeferredTextReference.cs
- WriteTimeStream.cs
- StateMachineHelpers.cs
- XmlSchemaCollection.cs
- RelAssertionDirectKeyIdentifierClause.cs
- Application.cs
- HelloOperationCD1AsyncResult.cs
- XMLSchema.cs
- SingleStorage.cs
- DesignTimeValidationFeature.cs
- UnsafeNativeMethods.cs
- Timer.cs
- InputLanguageEventArgs.cs
- XmlDocumentViewSchema.cs
- TranslateTransform3D.cs
- PropertyEntry.cs
- VirtualPathProvider.cs
- __FastResourceComparer.cs
- OptimalBreakSession.cs
- AddInSegmentDirectoryNotFoundException.cs
- EntityDataSourceWrapperCollection.cs
- DataServiceProviderWrapper.cs
- ImmutableCollection.cs
- __TransparentProxy.cs
- ObjectDataSourceView.cs
- errorpatternmatcher.cs
- BaseCodeDomTreeGenerator.cs
- ClientScriptManager.cs
- DataListComponentEditor.cs
- ProgressBar.cs
- PreviewPrintController.cs
- CodeSnippetCompileUnit.cs
- VectorAnimationUsingKeyFrames.cs
- XPathException.cs
- FormViewCommandEventArgs.cs
- SamlSecurityTokenAuthenticator.cs
- WindowsPrincipal.cs
- HtmlImage.cs
- BasicCellRelation.cs
- InvalidCastException.cs
- PopupControlService.cs
- PolyQuadraticBezierSegment.cs
- EditingMode.cs
- SafeHandle.cs
- TransportChannelListener.cs
- URI.cs
- SqlDelegatedTransaction.cs
- SchemaSetCompiler.cs
- MDIClient.cs
- CategoryNameCollection.cs
- ToolStripPanelSelectionBehavior.cs
- AsyncPostBackErrorEventArgs.cs