Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Base / MS / Internal / InheritanceContextHelper.cs / 1305600 / InheritanceContextHelper.cs
/****************************************************************************\ * * File: InheritanceContextHelper.cs * * This file holds a helper class for DO subclasses that implement an * inheritance context. * * Copyright (C) by Microsoft Corporation. All rights reserved. * \***************************************************************************/ using System; using System.Windows; using MS.Internal.WindowsBase; namespace MS.Internal { internal static class InheritanceContextHelper { //------------------------------------------------------------------- // // ProvideContextForObject // // Tell a DO that it has a new inheritance context available. // //------------------------------------------------------------------- [FriendAccessAllowed] // Built into Core, also used by Framework. internal static void ProvideContextForObject( DependencyObject context, DependencyObject newValue ) { if (context != null) { context.ProvideSelfAsInheritanceContext(newValue, null); } } //------------------------------------------------------------------- // // RemoveContextFromObject // // Tell a DO that it has lost its inheritance context. // //-------------------------------------------------------------------- [FriendAccessAllowed] // Built into Base, also used by Framework. internal static void RemoveContextFromObject( DependencyObject context, DependencyObject oldValue ) { if (context != null && oldValue.InheritanceContext == context) { context.RemoveSelfAsInheritanceContext(oldValue, null); } } //------------------------------------------------------------------- // // AddInheritanceContext // // Implementation to receive a new inheritance context // //-------------------------------------------------------------------- [FriendAccessAllowed] // Built into Base, also used by Framework. internal static void AddInheritanceContext(DependencyObject newInheritanceContext, DependencyObject value, ref bool hasMultipleInheritanceContexts, ref DependencyObject inheritanceContext ) { // ignore the request when the new context is the same as the old, // or when there are already multiple contexts if (newInheritanceContext != inheritanceContext && !hasMultipleInheritanceContexts) { if (inheritanceContext == null || newInheritanceContext == null) { // Pick up the new context inheritanceContext = newInheritanceContext; } else { // We are now being referenced from multiple // places, clear the context hasMultipleInheritanceContexts = true; inheritanceContext = null; } value.OnInheritanceContextChanged(EventArgs.Empty); } } //-------------------------------------------------------------------- // // RemoveInheritanceContext // // Implementation to remove an old inheritance context // //------------------------------------------------------------------- [FriendAccessAllowed] // Built into Base, also used by Framework. internal static void RemoveInheritanceContext(DependencyObject oldInheritanceContext, DependencyObject value, ref bool hasMultipleInheritanceContexts, ref DependencyObject inheritanceContext ) { // ignore the request when the given context doesn't match the old one, // or when there are already multiple contexts if (oldInheritanceContext == inheritanceContext && !hasMultipleInheritanceContexts) { // clear the context inheritanceContext = null; value.OnInheritanceContextChanged(EventArgs.Empty); } } } } // 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
- DragEventArgs.cs
- SoapHeaderException.cs
- WebPartConnectionsConnectVerb.cs
- ProfilePropertySettingsCollection.cs
- Descriptor.cs
- EmptyElement.cs
- WindowsBrush.cs
- PageHandlerFactory.cs
- WindowPatternIdentifiers.cs
- XmlSchemaInfo.cs
- MeasurementDCInfo.cs
- DescendentsWalkerBase.cs
- Block.cs
- RegionInfo.cs
- TreeNodeEventArgs.cs
- SqlDependency.cs
- SourceFileInfo.cs
- ProjectionPruner.cs
- HttpUnhandledOperationInvoker.cs
- WindowProviderWrapper.cs
- DbCommandTree.cs
- ItemList.cs
- Material.cs
- AccessViolationException.cs
- WebPartAuthorizationEventArgs.cs
- categoryentry.cs
- SamlDoNotCacheCondition.cs
- XpsSerializationManager.cs
- DetailsViewRowCollection.cs
- SizeAnimationUsingKeyFrames.cs
- EntityDataSourceStatementEditor.cs
- InvokeHandlers.cs
- httpstaticobjectscollection.cs
- Facet.cs
- DataGridViewRowsRemovedEventArgs.cs
- CodeDomSerializationProvider.cs
- EllipticalNodeOperations.cs
- WindowsProgressbar.cs
- EmptyReadOnlyDictionaryInternal.cs
- _AuthenticationState.cs
- DecoderExceptionFallback.cs
- TileBrush.cs
- SortDescription.cs
- DefaultValueAttribute.cs
- _AutoWebProxyScriptEngine.cs
- Events.cs
- TreeViewItem.cs
- XmlWrappingReader.cs
- ParameterCollection.cs
- FatalException.cs
- LookupBindingPropertiesAttribute.cs
- HtmlTableRowCollection.cs
- RegexCode.cs
- OracleParameterCollection.cs
- StateRuntime.cs
- _IPv4Address.cs
- PolygonHotSpot.cs
- EditorBrowsableAttribute.cs
- XmlSchemaAnnotated.cs
- SelectionEditor.cs
- CollectionChangedEventManager.cs
- ZipPackage.cs
- PropertyChangedEventArgs.cs
- Region.cs
- WSSecurityPolicy12.cs
- PolyLineSegmentFigureLogic.cs
- SerializationSectionGroup.cs
- WindowPattern.cs
- ProxyWebPartManager.cs
- BStrWrapper.cs
- ToggleButtonAutomationPeer.cs
- SmtpNegotiateAuthenticationModule.cs
- PriorityRange.cs
- HyperlinkAutomationPeer.cs
- CodeDefaultValueExpression.cs
- BigInt.cs
- RoleGroupCollection.cs
- SmtpFailedRecipientsException.cs
- CurrentChangedEventManager.cs
- StateWorkerRequest.cs
- BamlTreeUpdater.cs
- BoundField.cs
- XmlCountingReader.cs
- TextRunCacheImp.cs
- RelationshipEndMember.cs
- EnumerableCollectionView.cs
- ArgumentElement.cs
- ToolStripRenderer.cs
- ITextView.cs
- XmlBaseReader.cs
- IImplicitResourceProvider.cs
- KeyedHashAlgorithm.cs
- SHA256.cs
- sqlser.cs
- ToolboxItemAttribute.cs
- DelegateSerializationHolder.cs
- RunInstallerAttribute.cs
- ThicknessAnimation.cs
- Page.cs
- BaseDataBoundControlDesigner.cs