Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / Orcas / SP / ndp / fx / src / DataEntity / System / Data / Map / ViewGeneration / Validation / ViewCellSlot.cs / 2 / ViewCellSlot.cs
//---------------------------------------------------------------------- //// Copyright (c) Microsoft Corporation. All rights reserved. // // // @owner [....] // @backupOwner [....] //--------------------------------------------------------------------- using System.Collections.Generic; using System.Data.Mapping.ViewGeneration.Structures; using System.Text; using System.Data.Common.Utils; using System.Data.Mapping.ViewGeneration.Utils; using System.Data.Entity; namespace System.Data.Mapping.ViewGeneration.Validation { // Represents a slot that is projected by both cell queries in a cell internal class ViewCellSlot : ProjectedSlot { #region Constructor // effects: Creates a view cell slot that corresponds to slot number // "slotNum" in some cell -- the leftSlot and rightSlot represent the // slots in the left and right cellqueries at slot slotNum internal ViewCellSlot(int slotNum, JoinTreeSlot cSlot, JoinTreeSlot sSlot) { m_slotNum = slotNum; m_cSlot = cSlot; m_sSlot = sSlot; } #endregion #region Fields private int m_slotNum; private JoinTreeSlot m_cSlot; private JoinTreeSlot m_sSlot; // A comparer that can compare ViewCellSlots only (and not generic ProjectedSlots) internal static readonly IEqualityComparerSpecificEqualityComparer = new ViewCellSlotEqualityComparer(); #endregion #region Properties // effects: Returns the slot corresponding to the left cellquery internal JoinTreeSlot CSlot { get { return m_cSlot;} } // effects: Returns the slot corresponding to the right cellquery internal JoinTreeSlot SSlot { get { return m_sSlot; } } #endregion #region Comparer/String Methods protected override bool IsEqualTo(ProjectedSlot right) { ViewCellSlot rightSlot = right as ViewCellSlot; if (rightSlot == null) { return false; } return m_slotNum == rightSlot.m_slotNum && JoinTreeSlot.EqualityComparer.Equals(m_cSlot, rightSlot.m_cSlot) && JoinTreeSlot.EqualityComparer.Equals(m_sSlot, rightSlot.m_sSlot); } protected override int GetHash() { return JoinTreeSlot.EqualityComparer.GetHashCode(m_cSlot) ^ JoinTreeSlot.EqualityComparer.GetHashCode(m_sSlot) ^ m_slotNum; } // effects: Given a list of slots, converts the left/right slots (if left // is true/false) to a human-readable string internal static string SlotsToUserString(IEnumerable slots, bool isFromCside) { StringBuilder builder = new StringBuilder(); bool first = true; foreach (ViewCellSlot slot in slots) { if (false == first) { builder.Append(", "); } builder.Append(SlotToUserString(slot, isFromCside)); first = false; } return builder.ToString(); } internal static string SlotToUserString(ViewCellSlot slot, bool isFromCside) { JoinTreeSlot actualSlot = isFromCside ? slot.CSlot : slot.SSlot; string result = StringUtil.FormatInvariant("{0}", actualSlot); return result; } internal override StringBuilder AsCql(StringBuilder builder, MemberPath outputMember, string blockAlias, int indentLevel) { ExceptionHelpers.CheckAndThrowRes(false, () => Strings.ViewGen_Internal_Error); return null; // To keep the compiler happy } internal override void ToCompactString(StringBuilder builder) { builder.Append('<'); StringUtil.FormatStringBuilder(builder, "{0}", m_slotNum); builder.Append(':'); m_cSlot.ToCompactString(builder); builder.Append('-'); m_sSlot.ToCompactString(builder); builder.Append('>'); } #endregion #region ViewCellSlot Comparer class // Simply delegate the work to the ProjectedSlot.EqualityComparer internal class ViewCellSlotEqualityComparer : IEqualityComparer { public bool Equals(ViewCellSlot left, ViewCellSlot right) { return ProjectedSlot.EqualityComparer.Equals(left, right); } public int GetHashCode(ViewCellSlot key) { return ProjectedSlot.EqualityComparer.GetHashCode(key); } } #endregion } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //---------------------------------------------------------------------- // // Copyright (c) Microsoft Corporation. All rights reserved. // // // @owner [....] // @backupOwner [....] //--------------------------------------------------------------------- using System.Collections.Generic; using System.Data.Mapping.ViewGeneration.Structures; using System.Text; using System.Data.Common.Utils; using System.Data.Mapping.ViewGeneration.Utils; using System.Data.Entity; namespace System.Data.Mapping.ViewGeneration.Validation { // Represents a slot that is projected by both cell queries in a cell internal class ViewCellSlot : ProjectedSlot { #region Constructor // effects: Creates a view cell slot that corresponds to slot number // "slotNum" in some cell -- the leftSlot and rightSlot represent the // slots in the left and right cellqueries at slot slotNum internal ViewCellSlot(int slotNum, JoinTreeSlot cSlot, JoinTreeSlot sSlot) { m_slotNum = slotNum; m_cSlot = cSlot; m_sSlot = sSlot; } #endregion #region Fields private int m_slotNum; private JoinTreeSlot m_cSlot; private JoinTreeSlot m_sSlot; // A comparer that can compare ViewCellSlots only (and not generic ProjectedSlots) internal static readonly IEqualityComparerSpecificEqualityComparer = new ViewCellSlotEqualityComparer(); #endregion #region Properties // effects: Returns the slot corresponding to the left cellquery internal JoinTreeSlot CSlot { get { return m_cSlot;} } // effects: Returns the slot corresponding to the right cellquery internal JoinTreeSlot SSlot { get { return m_sSlot; } } #endregion #region Comparer/String Methods protected override bool IsEqualTo(ProjectedSlot right) { ViewCellSlot rightSlot = right as ViewCellSlot; if (rightSlot == null) { return false; } return m_slotNum == rightSlot.m_slotNum && JoinTreeSlot.EqualityComparer.Equals(m_cSlot, rightSlot.m_cSlot) && JoinTreeSlot.EqualityComparer.Equals(m_sSlot, rightSlot.m_sSlot); } protected override int GetHash() { return JoinTreeSlot.EqualityComparer.GetHashCode(m_cSlot) ^ JoinTreeSlot.EqualityComparer.GetHashCode(m_sSlot) ^ m_slotNum; } // effects: Given a list of slots, converts the left/right slots (if left // is true/false) to a human-readable string internal static string SlotsToUserString(IEnumerable slots, bool isFromCside) { StringBuilder builder = new StringBuilder(); bool first = true; foreach (ViewCellSlot slot in slots) { if (false == first) { builder.Append(", "); } builder.Append(SlotToUserString(slot, isFromCside)); first = false; } return builder.ToString(); } internal static string SlotToUserString(ViewCellSlot slot, bool isFromCside) { JoinTreeSlot actualSlot = isFromCside ? slot.CSlot : slot.SSlot; string result = StringUtil.FormatInvariant("{0}", actualSlot); return result; } internal override StringBuilder AsCql(StringBuilder builder, MemberPath outputMember, string blockAlias, int indentLevel) { ExceptionHelpers.CheckAndThrowRes(false, () => Strings.ViewGen_Internal_Error); return null; // To keep the compiler happy } internal override void ToCompactString(StringBuilder builder) { builder.Append('<'); StringUtil.FormatStringBuilder(builder, "{0}", m_slotNum); builder.Append(':'); m_cSlot.ToCompactString(builder); builder.Append('-'); m_sSlot.ToCompactString(builder); builder.Append('>'); } #endregion #region ViewCellSlot Comparer class // Simply delegate the work to the ProjectedSlot.EqualityComparer internal class ViewCellSlotEqualityComparer : IEqualityComparer { public bool Equals(ViewCellSlot left, ViewCellSlot right) { return ProjectedSlot.EqualityComparer.Equals(left, right); } public int GetHashCode(ViewCellSlot key) { return ProjectedSlot.EqualityComparer.GetHashCode(key); } } #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
- basemetadatamappingvisitor.cs
- MemberAssignment.cs
- RunInstallerAttribute.cs
- Trace.cs
- Journaling.cs
- CacheMemory.cs
- TaskHelper.cs
- ProfileService.cs
- CacheDependency.cs
- ServerReliableChannelBinder.cs
- ControlIdConverter.cs
- PagedDataSource.cs
- GenericAuthenticationEventArgs.cs
- TagNameToTypeMapper.cs
- SqlConnectionStringBuilder.cs
- _Semaphore.cs
- LongValidator.cs
- TableLayoutStyleCollection.cs
- SmtpReplyReaderFactory.cs
- GcSettings.cs
- HandleRef.cs
- XmlSerializerNamespaces.cs
- StylusPoint.cs
- ApplyTemplatesAction.cs
- MdImport.cs
- DataGridViewRowHeaderCell.cs
- PeerToPeerException.cs
- XmlSchemaAttribute.cs
- DesignerSerializerAttribute.cs
- UnsafeMethods.cs
- VirtualizingStackPanel.cs
- InstalledVoice.cs
- HtmlInputControl.cs
- DllNotFoundException.cs
- ParamArrayAttribute.cs
- HierarchicalDataBoundControl.cs
- XmlILAnnotation.cs
- ListManagerBindingsCollection.cs
- ToolStripPanelRenderEventArgs.cs
- IndependentlyAnimatedPropertyMetadata.cs
- Visitor.cs
- HScrollBar.cs
- WrappedKeySecurityToken.cs
- XmlSerializationGeneratedCode.cs
- PostBackTrigger.cs
- SimpleApplicationHost.cs
- FieldAccessException.cs
- DoubleLinkList.cs
- entityreference_tresulttype.cs
- EntityWrapperFactory.cs
- MailWriter.cs
- DiagnosticsConfiguration.cs
- XmlILStorageConverter.cs
- safex509handles.cs
- BitmapFrameEncode.cs
- StaticDataManager.cs
- BitmapFrameDecode.cs
- DynamicDiscoSearcher.cs
- CheckedPointers.cs
- NativeMethodsOther.cs
- SvcMapFile.cs
- _BufferOffsetSize.cs
- RuleSettings.cs
- ReadOnlyDictionary.cs
- GlyphShapingProperties.cs
- XmlReflectionMember.cs
- CodeExpressionStatement.cs
- RegistrySecurity.cs
- BulletChrome.cs
- AuthStoreRoleProvider.cs
- TemplateAction.cs
- WebPartExportVerb.cs
- WindowsScroll.cs
- WindowsGraphics2.cs
- COM2ExtendedBrowsingHandler.cs
- DesignerView.xaml.cs
- WindowsRegion.cs
- Stack.cs
- UnSafeCharBuffer.cs
- UDPClient.cs
- MulticastDelegate.cs
- WindowsGraphics.cs
- QuaternionIndependentAnimationStorage.cs
- PriorityBindingExpression.cs
- sqlcontext.cs
- DataGridViewRowDividerDoubleClickEventArgs.cs
- LinqDataSourceContextEventArgs.cs
- CfgSemanticTag.cs
- SendParametersContent.cs
- AccessDataSource.cs
- FrameworkElementAutomationPeer.cs
- ModuleConfigurationInfo.cs
- PrimaryKeyTypeConverter.cs
- MimeBasePart.cs
- EventLogger.cs
- FixedTextBuilder.cs
- ConnectionPoolManager.cs
- XmlReflectionImporter.cs
- EdmToObjectNamespaceMap.cs
- TreeSet.cs