Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Framework / System / Windows / Controls / ContainerTracking.cs / 1305600 / ContainerTracking.cs
//---------------------------------------------------------------------------- // // Copyright (C) Microsoft Corporation. All rights reserved. // //--------------------------------------------------------------------------- using System; using System.Collections; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Collections.Specialized; using System.ComponentModel; using System.Diagnostics; using System.Windows; using System.Windows.Controls.Primitives; using System.Windows.Input; namespace System.Windows.Controls { ////// Represents a node in a linked list used to track active containers. /// Containers should instantiate and references these. /// Parents hold onto the linked list. /// /// The list is iterated in order to call a variety of methods on containers /// in response to changes on the parent. /// internal class ContainerTracking{ internal ContainerTracking(T container) { _container = container; } /// /// The row container that this object represents. /// internal T Container { get { return _container; } } ////// The next node in the list. /// internal ContainerTrackingNext { get { return _next; } } /// /// The previous node in the list. /// internal ContainerTrackingPrevious { get { return _previous; } } /// /// Adds this tracker to the list of active containers. /// /// The root of the list. internal void StartTracking(ref ContainerTrackingroot) { // Add the node to the root if (root != null) { root._previous = this; } _next = root; root = this; } /// /// Removes this tracker from the list of active containers. /// /// The root of the list. internal void StopTracking(ref ContainerTrackingroot) { // Unhook the node from the list if (_previous != null) { _previous._next = _next; } if (_next != null) { _next._previous = _previous; } // Update the root reference if (root == this) { root = _next; } // Clear the node's references _previous = null; _next = null; } #region Debugging Helpers /// /// Asserts that the container represented by this tracker is in the list represented by the given root. /// [Conditional("DEBUG")] internal void Debug_AssertIsInList(ContainerTrackingroot) { #if DEBUG Debug.Assert(IsInList(root), "This container should be in the tracking list."); #endif } /// /// Asserts that the container represented by this tracker is not in the list represented by the given root. /// [Conditional("DEBUG")] internal void Debug_AssertNotInList(ContainerTrackingroot) { #if DEBUG Debug.Assert(!IsInList(root), "This container shouldn't be in our tracking list"); #endif } #if DEBUG /// /// Checks that this tracker is present in the list starting with root. It's a linear walk through the list, so should be used /// mostly for debugging /// private bool IsInList(ContainerTrackingroot) { ContainerTracking node = root; while (node != null) { if (node == this) { return true; } node = node._next; } return false; } #endif #endregion private T _container; private ContainerTracking _next; private ContainerTracking _previous; } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved. //---------------------------------------------------------------------------- // // Copyright (C) Microsoft Corporation. All rights reserved. // //--------------------------------------------------------------------------- using System; using System.Collections; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Collections.Specialized; using System.ComponentModel; using System.Diagnostics; using System.Windows; using System.Windows.Controls.Primitives; using System.Windows.Input; namespace System.Windows.Controls { /// /// Represents a node in a linked list used to track active containers. /// Containers should instantiate and references these. /// Parents hold onto the linked list. /// /// The list is iterated in order to call a variety of methods on containers /// in response to changes on the parent. /// internal class ContainerTracking{ internal ContainerTracking(T container) { _container = container; } /// /// The row container that this object represents. /// internal T Container { get { return _container; } } ////// The next node in the list. /// internal ContainerTrackingNext { get { return _next; } } /// /// The previous node in the list. /// internal ContainerTrackingPrevious { get { return _previous; } } /// /// Adds this tracker to the list of active containers. /// /// The root of the list. internal void StartTracking(ref ContainerTrackingroot) { // Add the node to the root if (root != null) { root._previous = this; } _next = root; root = this; } /// /// Removes this tracker from the list of active containers. /// /// The root of the list. internal void StopTracking(ref ContainerTrackingroot) { // Unhook the node from the list if (_previous != null) { _previous._next = _next; } if (_next != null) { _next._previous = _previous; } // Update the root reference if (root == this) { root = _next; } // Clear the node's references _previous = null; _next = null; } #region Debugging Helpers /// /// Asserts that the container represented by this tracker is in the list represented by the given root. /// [Conditional("DEBUG")] internal void Debug_AssertIsInList(ContainerTrackingroot) { #if DEBUG Debug.Assert(IsInList(root), "This container should be in the tracking list."); #endif } /// /// Asserts that the container represented by this tracker is not in the list represented by the given root. /// [Conditional("DEBUG")] internal void Debug_AssertNotInList(ContainerTrackingroot) { #if DEBUG Debug.Assert(!IsInList(root), "This container shouldn't be in our tracking list"); #endif } #if DEBUG /// /// Checks that this tracker is present in the list starting with root. It's a linear walk through the list, so should be used /// mostly for debugging /// private bool IsInList(ContainerTrackingroot) { ContainerTracking node = root; while (node != null) { if (node == this) { return true; } node = node._next; } return false; } #endif #endregion private T _container; private ContainerTracking _next; private ContainerTracking _previous; } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- LabelEditEvent.cs
- ToolStripPanelRenderEventArgs.cs
- NullableLongMinMaxAggregationOperator.cs
- SecurityTokenInclusionMode.cs
- XmlSecureResolver.cs
- ProgressBarAutomationPeer.cs
- PropertyFilterAttribute.cs
- BitStream.cs
- Logging.cs
- PersonalizationStateInfoCollection.cs
- Transform.cs
- ImageList.cs
- PeerConnector.cs
- BoolExpressionVisitors.cs
- ButtonStandardAdapter.cs
- DataGridViewHitTestInfo.cs
- Rect.cs
- InputScopeAttribute.cs
- ThemeableAttribute.cs
- BitmapEffectInputConnector.cs
- MatrixTransform.cs
- InvokeMethodActivityDesigner.cs
- EdmToObjectNamespaceMap.cs
- BitmapEffectInput.cs
- FilteredDataSetHelper.cs
- RuntimeResourceSet.cs
- ZipIOZip64EndOfCentralDirectoryBlock.cs
- WindowManager.cs
- Converter.cs
- Membership.cs
- BuildManager.cs
- serverconfig.cs
- DetectRunnableInstancesTask.cs
- WsiProfilesElementCollection.cs
- PixelFormatConverter.cs
- IODescriptionAttribute.cs
- VisemeEventArgs.cs
- TargetException.cs
- EmptyElement.cs
- unsafenativemethodsother.cs
- SqlConnectionHelper.cs
- DeferredElementTreeState.cs
- PanelContainerDesigner.cs
- Int32Converter.cs
- StringSorter.cs
- Normalization.cs
- DurationConverter.cs
- ObjectDataSourceView.cs
- QilBinary.cs
- XmlMembersMapping.cs
- CachedFontFamily.cs
- arc.cs
- TableCellAutomationPeer.cs
- ChildrenQuery.cs
- LogicalExpr.cs
- XpsThumbnail.cs
- ButtonStandardAdapter.cs
- ImageDrawing.cs
- HashCodeCombiner.cs
- HtmlTextArea.cs
- SubtreeProcessor.cs
- SystemIPGlobalStatistics.cs
- MappedMetaModel.cs
- AssemblySettingAttributes.cs
- SiteMapNodeCollection.cs
- RegistryConfigurationProvider.cs
- ListDictionaryInternal.cs
- CompositeFontParser.cs
- CodeSnippetStatement.cs
- PrimaryKeyTypeConverter.cs
- RelatedPropertyManager.cs
- RubberbandSelector.cs
- Literal.cs
- XmlNotation.cs
- IIS7WorkerRequest.cs
- PasswordPropertyTextAttribute.cs
- ExpressionPrefixAttribute.cs
- SqlDataSourceCache.cs
- DataStreamFromComStream.cs
- ResXFileRef.cs
- DBSqlParserTableCollection.cs
- WebPartDisplayMode.cs
- DescendantQuery.cs
- ObjectItemCollectionAssemblyCacheEntry.cs
- TypeResolvingOptionsAttribute.cs
- ScrollChrome.cs
- BamlLocalizableResource.cs
- PackageDigitalSignatureManager.cs
- QilFunction.cs
- NumericExpr.cs
- RelativeSource.cs
- EntitySqlQueryCacheKey.cs
- NativeMethods.cs
- WorkerRequest.cs
- WebPartTracker.cs
- FeatureAttribute.cs
- UnmanagedMarshal.cs
- EUCJPEncoding.cs
- SchemaObjectWriter.cs
- CapiHashAlgorithm.cs