Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / Orcas / NetFXw7 / wpf / src / Framework / MS / Internal / PrePostDescendentsWalker.cs / 1 / PrePostDescendentsWalker.cs
//------------------------------------------------------------------------------ // //// Copyright (C) Microsoft Corporation. All rights reserved. // // // Description: // A simple subclass of DescendentsWalker which introduces a second callback // which is called after a node's children have been visited. // // History: // 04/13/2004: rruiz: Introduces class. // 10/20/2004: rruiz: Moved class to MS.Internal. // //----------------------------------------------------------------------------- using System; using System.Diagnostics; using System.Windows; using MS.Utility; namespace MS.Internal { ////// A simple subclass of DescendentsWalker which introduces a second callback /// which is called after a node's children have been visited. /// internal class PrePostDescendentsWalker: DescendentsWalker { //----------------------------------------------------- // // Constructors // //----------------------------------------------------- #region Constructors /// /// Creates an instances of PrePostDescendentsWalker. /// /// specifies which tree should be visited first /// the callback to be called before a node's children are visited /// the callback to be called after a node's children are visited /// the data passed to each callback public PrePostDescendentsWalker(TreeWalkPriority priority, VisitedCallbackpreCallback, VisitedCallback postCallback, T data) : base(priority, preCallback, data) { _postCallback = postCallback; } #endregion Constructors //------------------------------------------------------ // // Public Methods // //----------------------------------------------------- #region Public Methods /// /// Starts the walking process for the given node. /// /// the node to start the walk on /// whether or not the first node should have the callbacks called on it public override void StartWalk(DependencyObject startNode, bool skipStartNode) { try { base.StartWalk(startNode, skipStartNode); } finally { if (!skipStartNode) { if (_postCallback != null) { // This type checking is done in DescendentsWalker. Doing it here // keeps us consistent. if (FrameworkElement.DType.IsInstanceOfType(startNode) || FrameworkContentElement.DType.IsInstanceOfType(startNode)) { _postCallback(startNode, this.Data); } } } } } #endregion Public Methods //------------------------------------------------------ // // Protected Methods // //------------------------------------------------------ #region Protected Methods ////// This method is called for every node touched during a walking of /// the tree. Some nodes may not have this called if the preCallback /// returns false - thereby preventing its subtree from being visited. /// /// the node to visit protected override void _VisitNode(DependencyObject d) { try { base._VisitNode(d); } finally { if (_postCallback != null) { _postCallback(d, this.Data); } } } #endregion Protected Methods //----------------------------------------------------- // // Private Properties // //------------------------------------------------------ #region Private Properties private VisitedCallback_postCallback; #endregion Private Properties } } // 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. // // // Description: // A simple subclass of DescendentsWalker which introduces a second callback // which is called after a node's children have been visited. // // History: // 04/13/2004: rruiz: Introduces class. // 10/20/2004: rruiz: Moved class to MS.Internal. // //----------------------------------------------------------------------------- using System; using System.Diagnostics; using System.Windows; using MS.Utility; namespace MS.Internal { ////// A simple subclass of DescendentsWalker which introduces a second callback /// which is called after a node's children have been visited. /// internal class PrePostDescendentsWalker: DescendentsWalker { //----------------------------------------------------- // // Constructors // //----------------------------------------------------- #region Constructors /// /// Creates an instances of PrePostDescendentsWalker. /// /// specifies which tree should be visited first /// the callback to be called before a node's children are visited /// the callback to be called after a node's children are visited /// the data passed to each callback public PrePostDescendentsWalker(TreeWalkPriority priority, VisitedCallbackpreCallback, VisitedCallback postCallback, T data) : base(priority, preCallback, data) { _postCallback = postCallback; } #endregion Constructors //------------------------------------------------------ // // Public Methods // //----------------------------------------------------- #region Public Methods /// /// Starts the walking process for the given node. /// /// the node to start the walk on /// whether or not the first node should have the callbacks called on it public override void StartWalk(DependencyObject startNode, bool skipStartNode) { try { base.StartWalk(startNode, skipStartNode); } finally { if (!skipStartNode) { if (_postCallback != null) { // This type checking is done in DescendentsWalker. Doing it here // keeps us consistent. if (FrameworkElement.DType.IsInstanceOfType(startNode) || FrameworkContentElement.DType.IsInstanceOfType(startNode)) { _postCallback(startNode, this.Data); } } } } } #endregion Public Methods //------------------------------------------------------ // // Protected Methods // //------------------------------------------------------ #region Protected Methods ////// This method is called for every node touched during a walking of /// the tree. Some nodes may not have this called if the preCallback /// returns false - thereby preventing its subtree from being visited. /// /// the node to visit protected override void _VisitNode(DependencyObject d) { try { base._VisitNode(d); } finally { if (_postCallback != null) { _postCallback(d, this.Data); } } } #endregion Protected Methods //----------------------------------------------------- // // Private Properties // //------------------------------------------------------ #region Private Properties private VisitedCallback_postCallback; #endregion Private Properties } } // 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
- Attachment.cs
- SynchronousReceiveElement.cs
- StructuralObject.cs
- MSAAWinEventWrap.cs
- TextSimpleMarkerProperties.cs
- XPathPatternParser.cs
- Mutex.cs
- _TransmitFileOverlappedAsyncResult.cs
- RTLAwareMessageBox.cs
- BitVector32.cs
- ObjectPropertyMapping.cs
- XamlStream.cs
- InfocardChannelParameter.cs
- SingleAnimationBase.cs
- ParameterBuilder.cs
- RelAssertionDirectKeyIdentifierClause.cs
- BindingContext.cs
- AudioFormatConverter.cs
- StructuralCache.cs
- DataBindingHandlerAttribute.cs
- WebPartTransformer.cs
- CompareInfo.cs
- SingleStorage.cs
- BaseTreeIterator.cs
- TextElementEditingBehaviorAttribute.cs
- OverflowException.cs
- ZipIOBlockManager.cs
- BlobPersonalizationState.cs
- RuleCache.cs
- DecimalConverter.cs
- AllMembershipCondition.cs
- SettingsPropertyCollection.cs
- DataSourceSelectArguments.cs
- ScrollBarRenderer.cs
- MenuItem.cs
- TextSelectionHighlightLayer.cs
- DefaultEventAttribute.cs
- XsltSettings.cs
- ToolStripControlHost.cs
- RowBinding.cs
- ObjectQuery_EntitySqlExtensions.cs
- ChannelListenerBase.cs
- RSACryptoServiceProvider.cs
- AuthorizationSection.cs
- TdsValueSetter.cs
- DoubleAnimationUsingPath.cs
- CollectionViewGroupRoot.cs
- BindingNavigatorDesigner.cs
- DbExpressionRules.cs
- RenderDataDrawingContext.cs
- CultureInfo.cs
- XsltCompileContext.cs
- Floater.cs
- ImageListUtils.cs
- TcpProcessProtocolHandler.cs
- EllipseGeometry.cs
- XmlLinkedNode.cs
- DefaultTextStoreTextComposition.cs
- UnsafeNativeMethods.cs
- ToolStripItemEventArgs.cs
- PolicyException.cs
- WebPartChrome.cs
- DataServiceConfiguration.cs
- NameNode.cs
- WindowsScrollBar.cs
- GeneralTransform3DCollection.cs
- SerializationAttributes.cs
- _UncName.cs
- ServiceDescriptionContext.cs
- SharedDp.cs
- SmiEventStream.cs
- SessionStateSection.cs
- XmlILStorageConverter.cs
- GlyphRunDrawing.cs
- TreeNodeSelectionProcessor.cs
- ProcessModelSection.cs
- ServiceNameCollection.cs
- BrowsableAttribute.cs
- NativeMethods.cs
- Rotation3DKeyFrameCollection.cs
- EngineSiteSapi.cs
- HtmlObjectListAdapter.cs
- TemplateBamlRecordReader.cs
- TextServicesContext.cs
- TableItemProviderWrapper.cs
- DbConnectionPoolGroup.cs
- TransactionsSectionGroup.cs
- RuntimeHelpers.cs
- TakeOrSkipWhileQueryOperator.cs
- _NestedSingleAsyncResult.cs
- IList.cs
- FillErrorEventArgs.cs
- DoubleStorage.cs
- SQLMoneyStorage.cs
- FontFamilyIdentifier.cs
- AttributeEmitter.cs
- AnchoredBlock.cs
- GuidelineCollection.cs
- CompilerParameters.cs
- XhtmlBasicValidatorAdapter.cs