Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / Orcas / NetFXw7 / wpf / src / Framework / System / Windows / FrameworkContextData.cs / 1 / FrameworkContextData.cs
using System.Windows.Threading; using MS.Utility; using System; using System.Collections.Generic; using System.Diagnostics; namespace System.Windows { internal class FrameworkContextData { public static FrameworkContextData From(Dispatcher context) { FrameworkContextData data = (FrameworkContextData)context.Reserved2; if (data == null) { data = new FrameworkContextData(); context.Reserved2 = data; } return data; } // Enforce never creating except via static constructor above. private FrameworkContextData() { } // // Property Invalidation of Inheritable Properties // // At the context level, we need to keep track of all inheritable property invalidations currently // in action. The reason that there can be multiple invalidations going on at the same time is because // an invalidation of one property can cause an invalidation of a different property. The result is that // the first invalidation *pauses* while the second invalidation is delivered to the tree. // // We keep track of these invalidations to be able to optimize a recursion of the same property // invalidation from an element to that element's children. FrameworkElement.InvalidateTree will // check the stack of walkers here and, if it finds a match, will conclude that a new DescendentsWalker // need not be spun up. And there was much rejoicing. // public void AddWalker(object data, DescendentsWalkerBase walker) { // push a new walker on the top of the stack WalkerEntry walkerEntry = new WalkerEntry(); walkerEntry.Data = data; walkerEntry.Walker = walker; _currentWalkers.Add(walkerEntry); } public void RemoveWalker(object data, DescendentsWalkerBase walker) { // pop the walker off the top of the stack int last = _currentWalkers.Count - 1; #if DEBUG WalkerEntry walkerEntry = _currentWalkers[last]; Debug.Assert((walkerEntry.Data == data) && (walkerEntry.Walker == walker), "Inheritance DescendentsWalker tracker removal failed"); #endif _currentWalkers.RemoveAt(last); } public bool WasNodeVisited(DependencyObject d, object data) { // check to see if the given property on the given object is going to be visited by the // DescendentsWalker on the top of the stack if (_currentWalkers.Count > 0) { int last = _currentWalkers.Count - 1; WalkerEntry walkerEntry = _currentWalkers[last]; if (walkerEntry.Data == data) { return walkerEntry.Walker.WasVisited(d); } } return false; } private struct WalkerEntry { public object Data; // either the inheritable DP being invalidated, or the AncestorChangedDelegate, or the ResourceChangedDelegate public DescendentsWalkerBase Walker; } private List_currentWalkers = new List (4); } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved. using System.Windows.Threading; using MS.Utility; using System; using System.Collections.Generic; using System.Diagnostics; namespace System.Windows { internal class FrameworkContextData { public static FrameworkContextData From(Dispatcher context) { FrameworkContextData data = (FrameworkContextData)context.Reserved2; if (data == null) { data = new FrameworkContextData(); context.Reserved2 = data; } return data; } // Enforce never creating except via static constructor above. private FrameworkContextData() { } // // Property Invalidation of Inheritable Properties // // At the context level, we need to keep track of all inheritable property invalidations currently // in action. The reason that there can be multiple invalidations going on at the same time is because // an invalidation of one property can cause an invalidation of a different property. The result is that // the first invalidation *pauses* while the second invalidation is delivered to the tree. // // We keep track of these invalidations to be able to optimize a recursion of the same property // invalidation from an element to that element's children. FrameworkElement.InvalidateTree will // check the stack of walkers here and, if it finds a match, will conclude that a new DescendentsWalker // need not be spun up. And there was much rejoicing. // public void AddWalker(object data, DescendentsWalkerBase walker) { // push a new walker on the top of the stack WalkerEntry walkerEntry = new WalkerEntry(); walkerEntry.Data = data; walkerEntry.Walker = walker; _currentWalkers.Add(walkerEntry); } public void RemoveWalker(object data, DescendentsWalkerBase walker) { // pop the walker off the top of the stack int last = _currentWalkers.Count - 1; #if DEBUG WalkerEntry walkerEntry = _currentWalkers[last]; Debug.Assert((walkerEntry.Data == data) && (walkerEntry.Walker == walker), "Inheritance DescendentsWalker tracker removal failed"); #endif _currentWalkers.RemoveAt(last); } public bool WasNodeVisited(DependencyObject d, object data) { // check to see if the given property on the given object is going to be visited by the // DescendentsWalker on the top of the stack if (_currentWalkers.Count > 0) { int last = _currentWalkers.Count - 1; WalkerEntry walkerEntry = _currentWalkers[last]; if (walkerEntry.Data == data) { return walkerEntry.Walker.WasVisited(d); } } return false; } private struct WalkerEntry { public object Data; // either the inheritable DP being invalidated, or the AncestorChangedDelegate, or the ResourceChangedDelegate public DescendentsWalkerBase Walker; } private List _currentWalkers = new List (4); } } // 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
- SqlUnionizer.cs
- TimeStampChecker.cs
- RoutedEvent.cs
- DocumentGridContextMenu.cs
- QueryStringParameter.cs
- ComponentResourceKeyConverter.cs
- TraceSection.cs
- UntypedNullExpression.cs
- CellConstant.cs
- Brush.cs
- EventProvider.cs
- ServerIdentity.cs
- CmsInterop.cs
- SqlIdentifier.cs
- CharUnicodeInfo.cs
- ListView.cs
- UpdateProgress.cs
- CodeCommentStatement.cs
- DataGridViewCellStyleChangedEventArgs.cs
- SqlNode.cs
- ColumnReorderedEventArgs.cs
- ColorBlend.cs
- FormViewInsertedEventArgs.cs
- ActivityStatusChangeEventArgs.cs
- MessageQueuePermissionEntry.cs
- WorkflowRuntimeSection.cs
- _HTTPDateParse.cs
- ErrorEventArgs.cs
- ToolStripMenuItem.cs
- AssemblyUtil.cs
- LogLogRecordEnumerator.cs
- DesignerForm.cs
- Geometry.cs
- Win32.cs
- SchemaRegistration.cs
- BufferedGraphicsManager.cs
- QfeChecker.cs
- RadioButtonBaseAdapter.cs
- ping.cs
- WindowPattern.cs
- CornerRadiusConverter.cs
- LastQueryOperator.cs
- RegexRunner.cs
- DbConnectionPoolOptions.cs
- DataProtection.cs
- XmlBindingWorker.cs
- SQlBooleanStorage.cs
- ModifierKeysValueSerializer.cs
- DataRow.cs
- CSharpCodeProvider.cs
- TriState.cs
- Select.cs
- EncoderParameters.cs
- TypeExtension.cs
- SmtpNetworkElement.cs
- XmlHierarchyData.cs
- ChtmlTextWriter.cs
- ExpressionBinding.cs
- panel.cs
- XmlSerializerSection.cs
- LicenseManager.cs
- FormsAuthenticationUser.cs
- KeyboardDevice.cs
- AuthenticationModuleElement.cs
- MimeTypeMapper.cs
- XmlSchemaAnyAttribute.cs
- CompiledQueryCacheEntry.cs
- HtmlInputImage.cs
- ExtenderProvidedPropertyAttribute.cs
- Point3DConverter.cs
- PropertyGridCommands.cs
- embossbitmapeffect.cs
- WindowsRegion.cs
- LinkButton.cs
- ImageFormatConverter.cs
- EntityDataSourceContainerNameConverter.cs
- WebPartAddingEventArgs.cs
- RenderDataDrawingContext.cs
- QilIterator.cs
- _Win32.cs
- GuidTagList.cs
- CodeEventReferenceExpression.cs
- WindowsRichEdit.cs
- Queue.cs
- SHA384.cs
- NameValuePermission.cs
- CollectionChange.cs
- FixedTextView.cs
- StringAnimationUsingKeyFrames.cs
- ListViewHitTestInfo.cs
- Int64Storage.cs
- Semaphore.cs
- GroupBox.cs
- MappingItemCollection.cs
- SemaphoreSecurity.cs
- WebPartAddingEventArgs.cs
- BamlLocalizationDictionary.cs
- FunctionQuery.cs
- SqlDataRecord.cs
- Enum.cs