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
- BuildResult.cs
- wgx_commands.cs
- DiscoveryReferences.cs
- InputLanguageEventArgs.cs
- ScaleTransform3D.cs
- CachingHintValidation.cs
- CellQuery.cs
- ParameterModifier.cs
- Hyperlink.cs
- HtmlImage.cs
- SynchronizedInputHelper.cs
- BufferedConnection.cs
- AsyncStreamReader.cs
- ClientType.cs
- DynamicILGenerator.cs
- SmiMetaDataProperty.cs
- RelationshipEndCollection.cs
- ArgIterator.cs
- UserInitiatedNavigationPermission.cs
- WorkflowInstanceTerminatedRecord.cs
- Enum.cs
- Int32.cs
- NonBatchDirectoryCompiler.cs
- DesignerVerb.cs
- PanelStyle.cs
- StreamGeometryContext.cs
- CommonXSendMessage.cs
- DetailsViewUpdatedEventArgs.cs
- AttributeProviderAttribute.cs
- ButtonBaseAdapter.cs
- _ServiceNameStore.cs
- SoapDocumentServiceAttribute.cs
- ThreadInterruptedException.cs
- RecordsAffectedEventArgs.cs
- RestHandlerFactory.cs
- CodeSnippetStatement.cs
- SqlMetaData.cs
- AnnotationMap.cs
- CharEntityEncoderFallback.cs
- InlineCollection.cs
- RefreshEventArgs.cs
- HoistedLocals.cs
- ComboBoxAutomationPeer.cs
- GeneralTransform3DCollection.cs
- FormViewPagerRow.cs
- HttpConfigurationContext.cs
- SqlBulkCopyColumnMapping.cs
- ClickablePoint.cs
- DataBinder.cs
- SQLRoleProvider.cs
- SwitchLevelAttribute.cs
- ContentAlignmentEditor.cs
- ConstNode.cs
- ObjectDataSourceStatusEventArgs.cs
- IdentifierCollection.cs
- BadImageFormatException.cs
- ModuleBuilderData.cs
- SafeNativeMethods.cs
- ModelVisual3D.cs
- UInt16.cs
- DocumentViewer.cs
- SafeArchiveContext.cs
- TemplateControlCodeDomTreeGenerator.cs
- SchemaExporter.cs
- AstNode.cs
- TemplateBuilder.cs
- GraphicsState.cs
- CommandBindingCollection.cs
- TextParaLineResult.cs
- RequestTimeoutManager.cs
- IisTraceWebEventProvider.cs
- HyperLinkStyle.cs
- OdbcFactory.cs
- XPathNavigatorReader.cs
- Query.cs
- HandleCollector.cs
- MatrixAnimationBase.cs
- CngAlgorithmGroup.cs
- DetailsViewPagerRow.cs
- Utils.cs
- QueryConverter.cs
- SyndicationCategory.cs
- SamlAttributeStatement.cs
- HotSpotCollection.cs
- ProgressiveCrcCalculatingStream.cs
- SimpleHandlerFactory.cs
- WebException.cs
- ErrorHandlerModule.cs
- VisualBasicReference.cs
- DispatcherObject.cs
- UriWriter.cs
- StoreAnnotationsMap.cs
- Soap.cs
- DBConnectionString.cs
- WrappedReader.cs
- CommandArguments.cs
- X509ChainPolicy.cs
- EventLogReader.cs
- XmlTypeAttribute.cs
- SpeechSeg.cs