Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / Orcas / QFE / wpf / src / Base / MS / Internal / InheritanceContextHelper.cs / 1 / 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. /****************************************************************************\ * * 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
- elementinformation.cs
- MLangCodePageEncoding.cs
- CommonDialog.cs
- ProcessProtocolHandler.cs
- DummyDataSource.cs
- MetafileHeader.cs
- WindowsUpDown.cs
- BroadcastEventHelper.cs
- Int64AnimationBase.cs
- ToolboxDataAttribute.cs
- WebSysDisplayNameAttribute.cs
- DataGridItemCollection.cs
- DataGridViewRowStateChangedEventArgs.cs
- ReadOnlyCollectionBase.cs
- SQLMembershipProvider.cs
- HMACMD5.cs
- TextTreeObjectNode.cs
- GridViewRowPresenter.cs
- bidPrivateBase.cs
- SpeechAudioFormatInfo.cs
- CanonicalizationDriver.cs
- WebPartMenuStyle.cs
- StackSpiller.Generated.cs
- ObjectStorage.cs
- TransactionCache.cs
- HierarchicalDataTemplate.cs
- ClrPerspective.cs
- TextSegment.cs
- RegexCompilationInfo.cs
- TextDecorationLocationValidation.cs
- Stack.cs
- TextWriterTraceListener.cs
- LineVisual.cs
- UInt16Converter.cs
- FilterableAttribute.cs
- SourceItem.cs
- ServiceHostingEnvironmentSection.cs
- Model3DGroup.cs
- CssStyleCollection.cs
- AuthStoreRoleProvider.cs
- RenderDataDrawingContext.cs
- Pkcs7Signer.cs
- CacheMemory.cs
- GregorianCalendar.cs
- DataViewSetting.cs
- DataGridParentRows.cs
- OleDbError.cs
- TableCell.cs
- PenThreadWorker.cs
- OneOf.cs
- BorderGapMaskConverter.cs
- AssemblyBuilder.cs
- InputBindingCollection.cs
- WebBrowsableAttribute.cs
- ClockGroup.cs
- TextLineResult.cs
- ProfileProvider.cs
- DbMetaDataCollectionNames.cs
- DbConnectionClosed.cs
- XmlWriter.cs
- ToolBarButton.cs
- SoapTypeAttribute.cs
- DesignerVerbCollection.cs
- FixUpCollection.cs
- CodeNamespaceImportCollection.cs
- Vector3DAnimation.cs
- HttpApplicationStateBase.cs
- DataGridPageChangedEventArgs.cs
- ListMarkerLine.cs
- DataGridViewButtonColumn.cs
- TextSearch.cs
- NumberFunctions.cs
- METAHEADER.cs
- ControlPaint.cs
- WaitForChangedResult.cs
- PathTooLongException.cs
- Preprocessor.cs
- Win32Native.cs
- WebPartZone.cs
- StatusStrip.cs
- Resources.Designer.cs
- DESCryptoServiceProvider.cs
- ResourcesGenerator.cs
- LassoHelper.cs
- LabelAutomationPeer.cs
- RtfToken.cs
- VisualStyleInformation.cs
- RadioButtonAutomationPeer.cs
- Int32AnimationUsingKeyFrames.cs
- WeakRefEnumerator.cs
- XPathExpr.cs
- KeyedHashAlgorithm.cs
- OleDbInfoMessageEvent.cs
- PeerFlooder.cs
- SerializableAttribute.cs
- SqlTriggerContext.cs
- DataControlImageButton.cs
- EdmTypeAttribute.cs
- DetailsViewInsertEventArgs.cs
- ProgramPublisher.cs